Assignment 1 : Introduction to Python shell
Topics
● Installation of Python
● Values and Types : int , float, str etc
● Variables : assignment statements , printing variable values , types of
variables
● Boolean operators, Logical operators
● Mathematical functions from math , cmath modules.
Q.1 : Use Python code to evaluate each of the following expressions:
23 12 12
1. 21 / 7 10+50 2. + , 3. − 3 52 , 4. 34 + 10
15 17 25
11−7
5. 25 % 10 + 7 − (5 +14) × 35 ÷ 3, 6. 5 + × 33 ,
6
7. | – 195 – 75 | 8. | − 25 | 9. 100 // 7
10. Find the reminder when 123 is divided by 15 11. 40 // 3 + 15 % 3
257
12. (15+ ) + 3(6 – 83 )
13
13. Assign a= 220, b=15 , c = 3 , d = 4, find a+c , a*b, c**d , a/b , a // b .
14. Find a + c, a b, cd, a/ b and a(b + c), where a = –5, b = 7, c = 3, d = 10.
15. Find the remainder when 2027 is divided by 17
Q.2: Using math module in python find values of :
𝜋 π
1. , 2. e, 3. , 4. e4 5. sin ( )
2 2
π 37
6. cos 7. cos 45 8. log(e3) 9. √1221 10. √
6 75
2𝜋
11. the gcd of 750 and 300 12. sin( ) 13. 7 !
3
9!
14. 15. sin–1 (1).
6!
Q.3: Find the data type of the following data by using Python.
a) “SPPU” b) 451.25 c) 10 + 7j d) “mathematics” e) 96, f) (1,2,3,4,5)
Q.4 :Using Python, evaluate the following expressions of complex numbers
z1 = 2+3j , z2 = −4 + 6j and z3= −9 + 3j
a) z1 +2 z2 , b) z1 − 5 z2 , c) z1 ∗ z2 , d) z1 + z3 , e) (z1 − z2)*z3
Q.5 : Find the values of the following expressions if x is true , y is false and z is
true.
(a) (x or y) and z.
(b) (x and y) or not z.
(c) (x or not y) or (x and z).
(d) (x and y) or (not z).
(e) (x and not y) and not z.
================== *================
Assignment 2: Python Strings
Accessing values in strings
● Updating strings
● String special operators
● Concatenation
● Repetition
Write Python Code to:
1. Define string s = 'Good Morning’ and print “Morning” using slicing of string ‘s’.
2. Define string s = 'Good Morning’ and add ‘Very’ to the beginning of the string ‘s’.
3. Input string s= “we are studying python ” and print its length.
4. Input string s= “python ” and print it 5 times.
5. Input strins s= “python ”, t = “is”, r=”easy” and make a new string
a=” python is easy”
6. Input a string “ xyzdrxzyxuinxyz ” replace xyz by by abc in it.
7. Input a string “ pqzdrxzyxupqxzyz ” , count ‘z’ in it also count “pq” in it.
8. Input any string and determine whether ‘z’ is in the given string or not .
Replace ‘z’ if exists by ‘#’.
9. Input any string and print whether it is lowercase or uppercase.
10. Input a string s= “ abcdpqrxyz and change it to uppercase.
11. Input a string and print whether it is numeric, alphanumeric or alphabetic string.
12. Input any string and reverse it.
13. Input a string and create a new string using only first 2 and last 3 letters of it.
14. Add 'ing' at the end of any given string.
15. Check whether a given string is a palindrome or not.
================ *===================
Assignment 3: Python List and Python Tuple
● Accessing Values
● Updating
● Delete elements
● Basic operations
● Indexing, Slicing
● Built-in Functions