Practical1 Python Programming
Practical1 Python Programming
Data Types, Input / Output Statements and Operators (Arithmetic, Relational, Logical,
Bitwise)
SAVE THE FILE AND UPLOAD AS (RollNo_Name_Exp1)
2. Compute areas of the following (Find the equation and implement in python):
1. Circle
2. Square
3. Sphere
4. Triangle
5. Rectangle
Theory:
Data types:
Number: int, float, complex
String
a = 11.80
x = 100
y = “Hello”
z = 3+5.j
print(a)
print(x)
1|Page
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
Course: Python Programming
PROGRAMME: B.(Tech.)/MBA(Tech.)
First Year AY 2022-2023 Semester: II
print(y)
print(z)
Output:
11.8
100
Hello
(3+5j)
# to accept numbers
num=int(input(‘Enter a number: ‘))
print(num)
Output:
Enter a number: 10
‘10’
Enter a number: 45
45
Enter a number: 78
78.0
x=6
y=89
print('The value of x is {1} and y is {0}'.format(x,y))
x = 12.3456789
print('The value of x is %3.2f' %x)
Output:
The value of x is 89 and y is 6
The value of x is 12.35
The value of x is 12.3457
The 12.35 and 456.8
2|Page
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
Course: Python Programming
PROGRAMME: B.(Tech.)/MBA(Tech.)
First Year AY 2022-2023 Semester: II
Operators:
Operators are used to perform operations on variables and values.
Python divides the operators in the following groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
+ x+y
- x-y
* x*y
/ x/y
% x%y
** x ** y
// x // y
= x=5
+= x += 3
-= x -= 3
*= x *= 3
/= x /= 3
3|Page
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
Course: Python Programming
PROGRAMME: B.(Tech.)/MBA(Tech.)
First Year AY 2022-2023 Semester: II
%= x %= 3
//= x //= 3
**= x **= 3
&= x &= 3
|= x |= 3
^= x ^= 3
>>= x >>= 3
<<= x <<= 3
== x == y
!= x != y
> x>y
< x<y
>= x >= y
<= x <= y
and Returns True if both statements are true x < 5 and x < 10
not Reverse the result, returns False if the result is not(x < 5 and x < 10)
true
is not Returns True if both variables are not the same object x is not y
not in Returns True if a sequence with the specified value is not x not in y
present in the object
<< Zero fill left Shift left by pushing zeros in from the right and
shift let the leftmost bits fall off
>> Signed right Shift right by pushing copies of the leftmost bit
shift in from the left, and let the rightmost bits fall
off
Operators:
x1 = 5
y1 = 5
x2 = ‘Hello’
y2 = ‘Hello’
# Output: False
print(x1 is not y1)
# Output: True
print(x2 is y2)
5|Page
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
Course: Python Programming
PROGRAMME: B.(Tech.)/MBA(Tech.)
First Year AY 2022-2023 Semester: II
x = 'Hello world'
# Output: True
print('H' in x)
# Output: True
print('hello' not in x)
Output:
False
True
True
True
PRACTICAL 1
6|Page
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
Course: Python Programming
PROGRAMME: B.(Tech.)/MBA(Tech.)
First Year AY 2022-2023 Semester: II
Part B (to be completed by students)
Data Types, Input / Output Statements and Operators (Arithmetic, Relational, Logical,
Bitwise)
(Students must submit the soft copy as per the following segments. A soft copy containing
Part A and Part B answered must be uploaded on the platform specified by the Practical
Teacher. The filename should be RollNo_Name_Exp1)
1. Program Code along with Sample Output: (Paste your programs [1,2,3,4,5], input and
output screen shot for programs [1,2,3,4,5])
2. Conclusion (Learning Outcomes): Reflect on the questions answered by you jot down
your learnings about the Topic: Data Types, Input / Output Statements and Operators.
7|Page