NEW
Font size
WorksheetsPython Fundamentals- 02
Total questions: 32
Worksheet time: 34mins
b = [11,13,15,17,19,21]
What is output for − print(b[::2])
[19,21]
[11,15]
[11,15,19]
[13,17,21]
When the given code is executed how many times ' 'you are learning python ' ' will be printed.
a = 0
while a<10:
print(''you are learning python'')
pass
9
10
11
Infinite number of times
What is the output of the following code?
var1 = 1
var2 = 2
var3 = "3"
print(var1 + var2 + var3)
6
33
123
Error. Mixing operators between numbers and strings are not supported
What is the output of the following code?
sampleList = ["Jon", "Kelly", "Jessa"]
sampleList.append("Scott")
print(sampleList)
[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]
[‘Jon’, ‘Kelly’, ‘Jessa’, ‘Scott’]
[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]
The program executed with errors
What is the output of the following
x = 36 / 4 * (3 + 2) * 4 + 2
print(x)
182.0
37
117
The Program executed with errors
What is the output of the following code?
p, q, r = 10, 20 ,30
print(p, q, r)
10 20
10 20 30
30 20 10
Error: invalid syntax
What is the output of the following code?
valueOne = 5 ** 2
valueTwo = 5 ** 3
print(valueOne)
print(valueTwo)
10
15
25
125
Error: invalid syntax
What is the output of the following code?
var = "James" * 2 * 3
print(var)
JamesJamesJamesJamesJamesJames
JamesJamesJamesJamesJames
Error: invalid syntax
What is the output of the following code?
var= "James Bond"
print(var[2::-1])
Jam
dno
maj
dnoB semaj
What is the output of the following code?
str = "pynative"
print (str[1:3])
py
yn
pyn
yna
A line of text that Python won't try to run as code
comment
variable
modulue
boolean
Symbol used for modulus
%
&
#
**
A data type that can have one of two values: True or False
boolean
Integer
String
Complex
102 = 100
Which of the following is used in Python to calculate ten squared?
10 ** 2
10 % 2
10 * 2
10 ** 10
A data type consisting of numbers, letters and symbols.
String
Float
Integer
Boolean
What is the position of the name 'Paula' in the following array:
names = ["Paul","Phillip","Paula","Phillipa"]
0
2
1
3
which of the following statements can be used to return the length of the given String, str?
size(str)
str.size()
len(str)
str._len_()
str='Hello World'
print (str.find('o'))
4, 7
7
4
2
str='Tech Beamers'
print (str[4:9])
Beamers
Beame
Beam
Beamer
What is the output when following statement is executed?
print ('Tech' 'Beamers')
Tech Beamers
TechBeamers
Beamers
Tech
Which of the answers would print the output as given below?
C:\Common\TestString.doc
str='''C:\Common\testString.doc'''
print (str)
str='C:\Commo\n\TestSt\ring.doc'
print (str)
str='C:\Common\TestStri\ng.doc'
print (str)
str='C:\Common\TestString.doc'
print (str)
What is the output of the following script when age = 50:
if age > 40:
if age > 60:
print('Turning old')
else:
print('Middle age')
else:
print('Young age')
Turning old
Middle age
Turning old
Middle age
Young age
Which of the following is a valid variable name in Python?
do it
do+1
1do
All of the above
None of the above
What does the following print?
x = 10 / 4
y = 5 / 2.0
print (x + y)
4
5.0
4.5
7
None of the above
Across how many lines will the following program’s output appear?
print ("how\nnow\tbrown/ncow?")
2
4
3
1
None of the above
Which of the following Boolean expression(s) implement the following statement?
x and y are not equal to zero, and they are either both positive or both negative (read carefully)
( x < 0 and y < 0 ) or ( x > 0 and y > 0 )
( x * y ) > 0
( x < 0 or x > 0 ) and ( y < 0 or y > 0 )
Two of the above are correct
All of the above are correct
Given the variables declared below, which expression evaluates to True?
a = 3
txt = "fun"
limit = 10
words = 5
a == limit - words
not ( words < limit )
( a > limit ) or ( len( txt ) < words )
words * a < limit
( len( txt ) > 0 ) and ( limit - words < a )
What kind of statement is the IF statement?
Concurrent
Assignment
Conditional Statement
Selected assignment
Which of the following commands will create a list?
list1 = list()
list1 = []
list1 = list([1, 2, 3])
all of the mentioned
What is the output when we execute list("hello")?
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
Error
None
25
2
What will be the output of the following Python code?
list("a#b#c#d".split('#'))
[‘a’, ‘b’, ‘c’, ‘d’]
[‘a b c d’]
‘a#b#c#d’]
[‘abcd’]
