Getting started with python
I) Identify the datatype for the
following: iv) a = 5.9
1. 123 n = int(a)
2. ‘Hello’ print(n)
3. 0b1110 print(type(n))
4. ‘Computer \t Science’
5. ‘A’ v) Assume that the input values are
6. 455.78 100 and 200
7. 10+7j mark_1=input(“Enter the first mark:”)
8. 0x12 mark_2= input(“Enter the first
9. False mark:”)
10.‘4578’ print(mark_1+mark_2)
II)Classify each of the following
tokens:(identifier, keywords, IV) Evaluate the following
literals, invalid) expressions:
a) 4 + 8 / 2 ** 2 / -2
Emp-code, _roll no, -4, x2, @email, b) 100 + 200 / 10 - 3 * 10
name’s, “python”, True, #count, c) 2**3+4//7-6*9
While, Bond007, [Link], for, Else, d) 5<10 and not((10<5)) or (3<18)
FALSE and not 8<18
e) 2/int(1.5)+200
III) Predict the output:
i)
a=2 V) Write logical expressions
m = [0, 5, 2, 3] corresponding to the
x = a * m[a] + m[1] following statements in
print(x) python.
a) 9.5 is between the values of
integers num1 and num2
ii) b) The sum of 60 and -15 is
a=3 greater than 30
b=3 c) var_1 is not less than var_2
c=1 d) num1 is equal to num2
x=a*3+7-5+b–c
print(x)
VI) If x=4, indicate what each
of the following python
iii) statements would print.
name = "Alex" a) print(“x”)
age = 0 b) print(‘x’)
print((name == "Alex" or name == c) print(x+1)
"John") and age >= 2) d) print(“x+1”)
e) print(‘x’+1)
f) print(x)