wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

Change to upper case

a)

upper = name.upper()

b)

upper = upper(name)

c)

lower = name.lower()

d)

up = name.upr()

2.

Change to capitalize each word

a)

Title = name.Title()

b)

title = name.title()

c)

Title= title(name)

3.

Write the code to get the following output

Hello Grade 5B

(a)  

4.

What is type casting ?

a)

Typecasting is a way of changing an object from one number to another.

b)

Typecasting is a way of changing an object from one word to another.

c)

Typecasting is a way of changing an object from one variable to another.

d)

Typecast is a way of changing an object from one data type to another type.

5.

Correct the following line of code so that the variable num1 will store the value as an integer

num1 = input("Enter a number")

a)

num1 = int(input("Enter a number"))

b)

num1 = input("Enter a number").int

c)

num1 = float(input("Enter a number"))

d)

num1 = str(input("Enter a number"))

6.

Predict the output for the following code:

number = 1

while number < 5:

print(number)

number = number + 1

a)

1

3

5

9

b)

2

3

4

c)

2

4

6

8

d)

Error

7.

What will be the output of the following code:

print(10 !=20)

a)

True

b)

False

c)

Syntax Error

8.

What will be the output of the following code:

print(50 ==70)

a)

True

b)

False

c)

Syntax Error

9.

What will be the output of the following code:

print(99>=100)

a)

True

b)

False

c)

Syntax Error

10.

Choose a number that will give you the output as Thank you! for the following code:

num = int(input("Enter a number: ")

if num > 10 :

print("Too high")

else:

print("Thank you! ")

a)

9

b)

9.5

c)

18

d)

3

11.

Would the output of

20//5

and the output of

20%5

be the same?

a)

Yes, they both will give the remainder

b)

No, the first line will give the remainder and the other will give the quotient

c)

Yes, they both will give the quotient

d)

No, the first line will give the quotient and the other will give the remainder

12.

number = random.randint(1,100)

a)

A random number between 1 to 99 will be displayed.

b)

A random number between 1 to 100 will be displayed.

c)

A random number between 0 to 100 will be displayed.

d)

A random number between 1 to 100 will be displayed.

13.

What will be the output of the following code :

num = random.randrange( 0,101,2)

a)

Displays a random number between the range of 0 to 101

b)

Displays a list of even number between the range of 0 to 100

c)

Displays a random odd number between the range of 0 to 100

d)

Displays a random even number between the range of 0 to 101

14.

Choose the correct syntax for creating a list in python

a)

fruit = [Apple, Mango, Grapes]

b)

fruit = ["Apple", "Mango", "Grapes"]

c)

fruit = ("Apple", "Mango", "Grapes")

d)

fruit = ["Apple""Mango""Grapes"]

15.

Choose the correct code to remove the item banana from the following python list:

fruit = ["Apple", "Mango", "Banana", "Grapes"]

a)

fruit.remove()

b)

fruit.remove("Banana")

c)

fruit.remove(Banana)

d)

fruit.remove("Banana")