COMPUTER SCIENCE
CLASS :XI PYTHON FUNDAMENTALS
Assignment – 1
Type- A
1. What are tokens in Python? How many types of tokens allowed in Python?
2. What are variables ? How are they important for a program ?
3. What factors guide the choice of identifiers in program?
4. What is the difference between a keyword and an identifier?
5. What are literals in Python? How many types of Literals allowed in Python?
6. How many types of Integer literals are allowed in python ?How are they written?
7. What is meant by floating literals in python?How many ways floating literals be
represented?
8. Write the following real constant into exponent form?
(i) 23.197 ii) 7.214 iii) 0.00005 iv) 0.319
9. Write the following real constants into fractional form?
i) 0.13E04 ii) 0.417E-04 iii) 0.4 E-5 iv) .12E02 v) 12.E02
10. How many types of sequences are supported in Python?
11. How many types of strings are supported by Python? Explain with Example.
12. What is None literal in Python?
13. Can nongraphic characters be used in Python ? How ? Give examples to support
your answer.
14. Which escape sequence represent the new line character and backspace
character? An escape sequence represents how many character.
15. How are string-literals represented and implemented in Python ?
16. Which of these is not a legal numeric type in Python ? (a) int (b) float (c) decimal.
17. Which argument of print( ) would you set for:
(i) changing the default separator (space) ?
(ii) printing the following line in current line ?
18. "Comments are useful and easy way to enhance readability and
understandability of a program." Elaborate with examples.
19. What are operators ? What is their function ?
20. What is an expression and a statement ?
21. What all components can a Python program contain ?
22. What do you understand by block/code block/suite in Python ?
23. What is the role of indentation in Python ?
24. What is Dynamic Typing feature of Python ?
Type- B
1. From the following, find out which assignment statement will produce an error.
State reason(s) too.
(a) x = 55
(b) y = 037
(c) z = 0o98
(d) 56thnumber = 3300
(e) length = 450.17
(f) !Taylor = 'Instant'
(g) this variable = 87.E02
(h) float = .17E - 03
(i) FLOAT = 0.17E - 03
2. How will Python evaluate the following expression ?
(i) 20 + 30 * 40 (ii) 20 - 30 + 40
(iii) (20 + 30) * 40 (iv) 15.0 / 4 + (8 + 3.0)
3. Find out the error(s) in following code fragments:
(i)
temperature = 90
print temperature
(ii)
a = 30
b=a+b
print (a And b)
(iii)
a, b, c = 2, 8, 9
print (a, b, c)
c, b, a = a, b, c
print (a ; b ; c)
(iv)
X = 24
4=X
(v)
print("X ="X)
(vi)
else = 21 - 5
4. What will be the output produced by following code fragment (s) ?
(i) X = 10
X = X + 10
X=X-5
print (X)
X, Y = X - 2, 22
print (X, Y)
(ii)
first = 2
second = 3
third = first * second
print (first, second, third)
first = first + second + third
third = second * first
print (first, second, third)
(iii)
side = int(input('side') ) #side given as 7
area = side * side
print (side, area)
5.What is the problem with the following code fragments ?
(i)
a=3
print(a)
b=4
print(b)
s=a+b
print(s)
6. . Identify the type of literals for each:
(i) 123 Numerica (ii) “Hello” String
(iii) “Bye\nSee You‟ iv) “A‟ (v) 345.55
(vi) 10+4j (vii) 0x12
7. What is the size of each string?
(i) “Python‟
(ii) “Learning@\nCS‟
(iii) “\table‟
8. Output of :
(i) True + True =
(ii) 100 + False =
(iii) -1 + True =
(iv) bool(-1 + True)
9. Output of
(i) 2 * 7 =
(ii) 2 ** 7 =
(iii) 2**2**3 =
(iv) 17 % 20 =
(v) not(20>6) or (19>7) and (20==20)
10. Output of :
a,b,c = 20,40,60
b+=10
c+=b
print(a,b,c)
11. Num = 100
Isok = False
print(type(Num))
print(type(Isok))
12 .Following code is trying to create a tuple with a single item. But when we try to
obtain the length of the tuple, Python gives error. Why ? What is the solution?
>>> t=(6)
>>> len(t)
Trackback : most recent call last
File “<python shell #8>”, line 1 in module
len(t)
Type error : object of type int has no len()
13. What will be the output product by the following code?
>> A = 9.0
>> print (A/4)
>> print (A//4)
14. Find the Output:
a)
s=input()
print(s,type(s))
s1=int(input)
print(s1,type(s))
s2=float(input())
print(s2,type(s2)
b) a = input () # Give the input as 500
b = input () # Give the input as Python
c=a+b
print( a+ b)
print(len(c))
print (a * b)
print( int(a) * b)
c) a=input() # Give the input as 6+5*4
print(a,a[0],a[1])
a=int(input()) # Give the input as 6+5*4
print(a)
b=bool(int(input()) # Give the input as 0
print(b)
d)
a=eval(“5”)
a1=eval(“5.5+34*7//2”)
print(a,type(a),a1,type(a1))
a2=eval(input()) # Give the input as python
a3=list(input()) # Give the input as Python
print(a2,a3)
e)
a4=eval(input()) # Give the input as 20,30,40
print(type(a4))
a5=eval(input()) # Give the input as [20,30,40]
print(type(a5))