Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Module 1 Practicals

Uploaded by

adithyahegdee2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Module 1 Practicals

Uploaded by

adithyahegdee2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MODULE 1 PRACTICAL CLASS

Exercise 1
Installation of Python and using Python Interpreter
Exercise 2
Installation of Anaconda and using Jupyter notebook
Exercise 3
Using Online Python
Exercise 4
Simple problems
Print (“Hello World”), print another 5 letters/words/numbers
Exercise 5
Data types:
Find the data types of 2, 2.0, “Welcome to MITE” ….etc..
Exercise 6:
Variables
1. Create a variable using assignment statement
2. Find the type of these variables: x=2, a=2.99, y=”mango”
3. Find the value of these variables
4. Try these variable names: a, x, message, 18bus num, more@,
class
Exercise 7:
Statements (expression,assignment) and script:
Print(1)
X=2
Print(x)
1
2
Exercise 8:
Operators:
a. Mathematical operators:
small sums using + - * /
using // and % (extract last 1,2 or 3 digits of a large number)
Precedence problems like (8+9)*3 and (8−2)÷2+4*2
b. comparative opeartors:
Find out if …
X is the same as y
X is not the same as y
X is greater than y
X is lesser than y
X is greater than or equal to y
X is lesser than or equal to y
X is y
X is not y
C. Logical operators
Check if x is greater than 0 and lesser than 10
Check if y is greater than 0 or lesser than 10
Check if z is not greater than 0 and lesser than 10
Exercise 9:
Functions:
Functions and argument. Give examples
Types of functions – built-in and user-defined
1. Built-in:
Max
Min
Len
Type conversion
Math functions
Random numbers
2. User-defined:
>>> def print_lyrics():
... print("I'm a lumberjack, and I'm okay.")
... print('I sleep all night and I work all day.')

>>> print_lyrics()

3. Recursive function:

Def countdown(n):
if n <= 0:
print(Blast off!)
else:
print(n)
countdown(n-1)

You might also like