0% found this document useful (0 votes)
17 views6 pages

Revision Worksheet 1

The document is a revision worksheet covering various topics in Python programming and computer science. It includes exercises on literals, identifiers, error identification in code, output prediction for given code snippets, Boolean expressions, and types of errors. Additionally, it addresses concepts related to Python modules, logic gates, and the characteristics of identifiers.

Uploaded by

9080213121s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

Revision Worksheet 1

The document is a revision worksheet covering various topics in Python programming and computer science. It includes exercises on literals, identifiers, error identification in code, output prediction for given code snippets, Boolean expressions, and types of errors. Additionally, it addresses concepts related to Python modules, logic gates, and the characteristics of identifiers.

Uploaded by

9080213121s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

REVISION WORKSHEET

1. Identify the types of following literals:


i. 23.789 ii. False iii. “True”. iv. 34.71E-4
v. None vi. 4+3j
2. Identify valid or invalid identifiers:
i. True ii. Student-Name iii. IF iv. PRINT
v. 1stAge. vi. Number1
3. Find out the error in following code and underline each correction.
Salary= int(input(“Salary :”) )
IF salary == 60000
Bonus=10/100 * Salary
Else:
Bonus = 0
Print ( Bonus )
4. What will be the output of following code :
a, b = 10, 2
a, b, a= a +5, b+2, a+4
print(a, b)
5 .What will be the output of following code:
print("Hi", "Manoj!","Good Morning", sep="#", end="$$>")
print("its", "a pleasant day.",end=”@@@”)
print("Do something good for society")
6 . What will be value of x after evaluation of each of following separately:
i. x = 29 / 5
ii. x = 39 // 4 * 2
iii. x = 3 ** 2 ** 2
iv. x = 2 ** 5 % 3 -5
v. x=(200>100) and (3==3.0) or not( 9 != 10)
vi. x=12 > 15 and 8 > 12 or not 19 > 4
7. Identify the type of Token:(in python)
i) D_O_B ii) True
iii) * iv) if
8. Convert as directed
i) (100110101)2 → ( ? )10
ii) (1110100101)2 → ( ? )8
iii) (1110100101)2 → ( ? )16
iv) (245)10 → (?)2
v) (245)10 → (?)8
vi) (245)10 → (?)16
vii) (E8A)16 → (?)8
viii) (E8A)16→ (?)10
ix) (E8A)16 → (?)2
x) (127)8 → (?)10
xi) (127)8 → (?)16
xii) (127)8 → (?)2
9. Draw the table of combinations and draw the logic circuit diagram for the following boolean expressions.
i) A’B + A’B’
ii) ABC’ + BC + A’BC
10. What will be the output of following Python code?
a= 12
b= 7.4
c= 1
a-= b
print(a, b)
a*= 2 + c
print(a)
b+= a*c
print(b)
11. State the following Boolean algebraic laws and prove using truth table.
Properties of 0s and 1s.
Involution
Idempotence law
Commutative law
Distributive law
Demorgan’s theorem
Absorption law
Complementary law
12. Explain the following types of tokens in python.
Keywords, identifiers, operators, literals, punctuators
13. Explain the following types of operators in python.
Unary operator
Binary operator – arithmetic, relational, logical, membership, assignment, augmented assignment, identity
14. Identity the following statements as valid / invalid python statements with reason.
m_n_q = 3500
m.n.q = 3500, 3600, 3700
m, n,m = 3500, 3600, 3700
C=float (input (“enter mark “)) note: Input entered is 78
C=float (input (“enter mark “)) note: Input entered is seventy-eight.
N1+n2+n3=sum
15. find the output of the following code fragment
A,B = 10,7
A,C=B/7 , B//7. A , B = 1.0 ,1
D=” good”
E=”morning “
Print( D+E)
Print ( “ the values of A,B,C are “, A,B,C) 1.0 7 1
Print ( E + 3) Error
Print ( E + D)
Print ( D * 2) goodgood
Print ( D*E) Error
16. Predict the output of the following code:
x=3
if x>2 or x<5 and x==6: T OR T AND F
print(“ok”)
else:
print(“no output”)
17 What will be output after execution of the following code?
a=11
b=5
if (a%b==0):
print (“Divisible”)
if (a//b==0):
print (“Answer”)
else:
print (“Not Divisible”)
18 Consider the string str=”Green Revolution”. Find the output for the given statements
i. str[3] ii. str [-3] iii. str[2:6] iv. len(str) v. str[-10:-2]
19. explain the types of errors in python
Syntax , semantic , logical , compile time and runtime errors
20. Python modules
math module – ceil(),floor(),sqrt(),exp(),fabs(),log(),pow(),sin(),cos(),tan(),degree(),radians()
random module – random(), randint(), randrange()
statistic module – mean(), median(), mode()
21. Write the equivalent Boolean expression for the following circuit.

22. ISCII can represent ______bit character


a.5 b. 6
c. 7 d. 8

23. What is the maximum possible length of an identifier?


a. 16 b. 32
c. 64 d. None of these

24. Which character is used in Python to make a single line comment?


a. / b. //
c. # d. !

25. Which of the following is not a keyword in Python language?


a. for b. if
c. try d. sum

26 Which of the following is not a valid identifier?


a. sum b. 1sum
c. sum_marks d. _sum

27. Pictorial representation of an algorithm is called as________.


a. Pseudo-code b. Program
c. Flow Chart d. Figure

28 Which of the following is an invalid statement?


a. abc = 1000 b. a b c = 1000 2000 3000
c. a,b,c = 1000, 2000, 3000 d. a_b_c = 1000

29. Which one of these is floor division?


a. / b. //
c. % d. None of the mentioned

30. What is the output of this expression, 3*1**3?


a. 1 b. 27
c. 9 d. 3
31. Operators with the same precedence (except power operator) are evaluated in which manner?
a. Left to Right b. Right to Left
c. Can’t say d. None of the mentioned

32. Choose correct option :


str1=”My”+”Work”
Statement 1: Value of str1 will be “MyWork”.
Statement 2: Operator ‘+’ concatenates the string if both operands are strings.
a. Only Statement 1 is true.
b. Only Statement 2 is true.
c. Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
d. Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

33. Choose correct option :


1st_number=23
Statement 1: Above statement is correct.
Statement 2: Identifier can’t have any special characters other than _ , digits , uppercase or lowercase
characters.
a. Only Statement 1 is true.
b. Only Statement 2 is true.
c. Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
d. Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

34. Which of the following is an escape sequence for a tab character ?


a) \a b) \t
c) n d) \b

35. Which of the following is not a valid identifier in python :


a) FILE13 b) _Check_Disk
c) My.file d) Z02TM

36. Which of the following is an bitwise operator in python ?


a) >= b) //
c) & d) %%

37. What is the value of x ?


x = int (13.25 +4/2)
a) 17 b)14
c) 15 d) 23

38. what will be the output of the following code statements.

a) (17 % 5) is (17 % 5) True

b) (17 % 5) == (17 % 5.0) True

c) type (17 % 5) == type (17 % 5.0) False

d) 17 // 5 3

e) 17 // 5.0 3.0

39 What will be the result of this code: ‘2’ + 3


a) 5 b) 23 c) Error d) 1
40 . What will be the result of this code: ‘*’ * 3
a) Error b) *3 c) *** d) 3*

41 The expression “Tutor” <=”Tutorial” returns


a) 1 b) True c) 0 d) False

42 The output of a two-input OR gate is high when


1. both inputs are low
2. both inputs are high
3. any one input is high
4. only one input is high

43 The output of a two-input AND gate is high when


1. both inputs are low
2. both inputs are high
3. any one input is high
4. only one input is high

44 Which of the following is a language translator?


1. Word Processor
2. Window 7
3. Compiler
4. Window 10

45 Which unit is responsible for converting the data received from the user into computer understandable format?
1. Memory Unit
2. Arithmetic and Logic Unit
3. Input Unit
4. Output Unit

46 Cache Memory is :
1. High Speed Memory
2. Permanent Memory
3. Slow Speed Memory
4. Both A and B

47 What is the purpose of control unit?


1. Perform Calculation
2. Controls flow of data and instructions
3. Stores data and instructions
4. Memory management

48 Compiler is an example of:


1. Application Software
2. System Software
3. Utility Software
4. All of the above

49 Python programs using conditional statements

50. Draw the flow chart based on the program given .

You might also like