wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Session 2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is a correct way to declare a variable in Python?

a)

int x = 5

b)

x = 5

c)

declare x = 5

d)

var x = 5

2.

Which data type is used to store textual data in Python?

a)

int

b)

float

c)

string

d)

bool

3.

How do you take user input in Python and store it in a variable named name?

a)

name = get_input("Enter your name: ")

b)

name = input("Enter your name: ")

c)

name = input_string("Enter your name: ")

d)

name = get_string("Enter your name: ")

4.

What will be the output of the following code if the user enters "Alice"?

a)

Hello, Alice

b)

Hello,

c)

Hello, name

d)

Enter your name: Alice

5.

What is the result of the following code?

a)

7

b)

5

c)

2

d)

Error

6.

How do you check if a number stored in variable x is greater than 10?

a)

if x > 10:

b)

if (x > 10)

c)

if x is greater than 10:

d)

if x > 10 then:

7.

What will be the output of the following code?

a)

x is greater than 5

b)

x is not greater than 5

c)

x = 3

d)

Error

8.

What will be the output of the following code?

a)

HELLO, WORLD!

b)

hello, world!

c)

Hello, World!

d)

error

9.

What is the correct way to check if a string s is empty in Python?

a)

if s == ""

b)

if s.isEmpty()

c)

if s.empty()

d)

if s == None

10.

Which of the following is the correct syntax to comment a single line in Python?

a)

// This is a comment

b)

# This is a comment

c)

This is a comment

d)

// This is a comment //