worksheet Python Revision Tour-1
worksheet Python Revision Tour-1
Question 1
Which of the following is an invalid variable?
1. my_day_2
2. 2nd_day
3. Day_two
4. _2
Question 2
Find the invalid identifier from the following:
1. name
2. break
3. section
4. mark12
Question 3
Which of the following is not a keyword?
1. eval
2. assert
3. nonlocal
4. pass
Question 4
Which of the following cannot be a variable?
1. _init_
2. in
3. it
4. on
Question 5
Which of these is not a core data type?
1. Lists
2. Dictionary
3. Tuples
4. Class
Question 6
How w ould you write xy in Python as an expression ?
1. x^y
2. x**y
3. x^^y
4. none of these
Question 7
What will be the value of the expression?
14 + 13 % 15
1. 14
2. 27
3. 12
4. 0
Question 8
Evaluate the expression given below if A = 16 and B = 15.
A % B // A
1. 0.0
2. 0
3. 1.0
4. 1
Question 9
What is the value of x?
x = int(13.25 + 4/2)
1. 17
2. 14
3. 15
4. 23
x = int(13.25 + 4/2)
Question 10
The expression 8/4/2 will evaluate equivalent to which of the following expressions:
1. 8/(4/2)
2. (8/4)/2
Question 11
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
1. <<, >>
2. **
3. I
4. %
Question 12
Which of the following expressions results in an error?
1. float('12')
2. int('12')
3. float('12.5')
4. int('12.5')
Question 13
Which of the following statement prints the shown output below?
hello\example\test.txt
1. print("hello\example\test.txt")
2. print("hello\\example\\test.txt")
3. print("hello\"example\"test.txt")
4. print("hello"\example"\test.txt")
Question 15
Which two operators can be used on numeric values in Python?
1. @
2. %
3. +
4. #
Question 16
Which of the following four code fragments will yield following output?
Eina
Mina
Dika
Select all of the function calls that result in this output
1. print('''Eina
\nMina
\nDika''')
2. print('''EinaMinaDika''')
3. print('Eina\nMina\nDika')
4. print('Eina
Mina
Dika')
1. print('''Eina
\nMina
\nDika''') — It is a multiline string and by adding \n extra line will be
added.
Question 17
Which of the following is valid arithmetic operator in Python :
1. //
2. ?
3. <
4. and
Question 18
For a given declaration in Python as s = "WELCOME", which of the following will be the
correct output of print(s[1::2])?
1. WEL
2. COME
3. WLOE
4. ECM
Question 19
Which of the following is an incorrect Logical operator in Python?
1. not
2. in
3. or
4. and
Question 20
Which of the following is not a Tuple in Python?
1. (1,2,3)
2. ("One","Two","Three")
3. (10,)
4. ("One")
.
Fill in the Blanks
Question 1
The smallest individual unit in a program is known as a token.
Question 2
A token is also called a lexical unit.
Question 3
A keyword is
Question 3
A keyword is a word having special meaning and role as specified by programming language.
Question 4
The data types whose values cannot be changed in place are called immutable types.
Question 5
In a Python expression, when conversion of a value's data type is done automatically by the
compiler without programmer's intervention, it is called implicit type conversion.
Question 6
Question 7
Question 8
A break statement skips the rest of the loop and jumps over to the statement following the
loop.
Question 9
The continue statement skips the rest of the loop statements and causes the next iteration of
the loop to take place.
Question 10
True/False Questions
Question 1
Question 2
The value of the expressions 4/(3*(2 - 1)) and 4/3*(2 - 1) is the same.
= 1.33333
Question 3
The value of the expressions 4/(3*(4 - 2)) and 4/3*(4 - 2) is the same.
4/3*(4-2)
= 4/3*2
= 1.3333*2
= 2.6666
Question 4
Question 5
A string can be surrounded by three sets of single quotation marks or by three sets of double
quotation marks.
Question 6
Question 7
Question 8
Question 9
Question 10
In a nested loop, a break statement terminates all the nested loops in one go.
Question 1
Assertion. Assigning a new value to an int variable creates a new variable internally.
Question 2
Reason. Python is case sensitive and its basic selection and looping statements are in lower
case.
Question 4
Reason. Python is case sensitive and its basic selection and looping statements are in lower
case.
Question 5
Assertion. The break statement can be used with all selection and iteration statements.
Reason. Using break with an if statement is of no use unless the if statement is part of a
looping construct.
Question 6
Assertion. The break statement can be used with all selection and iteration statements.