wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PythonDataStructure

Total questions: 21

Worksheet time: 5mins

Name
Class
Date
1.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
2.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
3.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
4.

Choose the statement that assigns 4 to the power of 3 to the variable new_var...

a)

new_var = 4 ** 3

b)

new_var = 3 ** 4

c)

new var = 3 ** 4

d)

new_var = 4 ^^ 3

5.
What is the output from this program?
a)
5
7
9
A python is a non-venomous snake
done
b)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
done
c)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake 
A python is a non-venomous snake
done
d)
done
6.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

7.

x = 5

y = 6

print("x*y")


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

8.

cakeAmount = raw_input()

print "We have", cakeAmount, " cakes"


The above code is run. You type:

six


Select the correct output.

a)

We have six cakes

b)

We have 6 cakes

c)

We havesix cakes

d)

Syntax Error

9.

age = input("Enter Age (as integer): ")

newAge = age + 20

print ("your age in 20 years is:", newAge)


you enter

15

a)

value of age is 15

value of newAge is 35

output is: your age in 20 years is: 35

b)

value of age is 15

value of newAge is 20

output is: your age in 20 years is: 20

c)

value of age is 15

value of newAge is "age + 20"

output is: your age in 20 years is: 35

d)

value of age is 15

value of newAge is 35

output is: your age in 20 years is:35

10.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
11.

people = ["John", "Rob", "Bob"]

print (people[4])

what would this result be?

a)
John
b)
Rob
c)
Bob
d)
Error
12.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
13.

Find T ?

T=144 / 2 + 5 * 9 - ( 8 -3 )

a)

106

b)

688

c)

112

d)

684

14.

Find the Output:

Item = {"ECE" , "CSE" , "EEE" , "CIVIL"}

Item.add (2,"MECH")

print(Item)

a)

{ "ECE" , "MECH" , "CSE" , "EEE" , "CIVIL" }

b)

{ "ECE" , "CSE" , "MECH" , "EEE" , "CIVIL" }

c)

{ "ECE" , "CSE" , "EEE" , "CIVIL" }

d)

{ "ECE" , "CSE" , "EEE" ,"MECH" , "CIVIL" }

15.

what is the output of the following code ?

var1 = 1

var2 = 2

var3 = "3"


print (var + var2 var3)

a)

Error. Mixing operators between numbers and strings are not supported

b)

6

c)

33

d)

123

16.

Which of the following function convert a string to a float in python ?

a)

float(X)

b)

int(x[,base])

c)

long(X[,base])

d)

str(X)

17.

what is the output of the above program ?

a)

[ 'AB' , 'CD' ]

b)

[ 'ab' , 'cd' ]

c)

[ AB , CD ]

d)

ERROR

18.

find p ?

p = ( 35 , 46 , 73 , 21 )

p.append( -2 , 24 )

print (p)

a)

( 35 , 46 , 73 , 24 , 21 )

b)

error

c)

( 35 , 46 , 24 , 73 , 21 )

d)

( 35 , 24 , 73 , 21 )

19.

Find the output ?

a)

infytq

b)

INFYTQ

c)

ERROR

20.
What will the output be from the following code?
print("Hello world!" * 2 * "Hello world!")
a)
TypeError
b)
Hello world! Hello world! Hello world! Hello world!
c)
Hello Hello World! World!
d)
Hello world! Hello world!
21.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2