wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PPS QUIZZ 1

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which of the following is a valid variable name in Python?

a)

a) 2variable

b)

b) _variable

c)

c) variable@

d)

d) var#iable

2.

What will be the output of the following Python code?

a = 5

b = a

a = 10

print(b)

a)

a) 5

b)

b) 10

c)

c) Error

d)

d) None

3.

Which of the following rules is correct for naming a variable in Python?

a)

a) A variable name can start with a number

b)

b) A variable name can contain spaces

c)

c) A variable name can start with an underscore

d)

d) A variable name can contain special characters like @, #, and $

4.

What is the purpose of the assignment operator in Python?

a)

a) To compare two values

b)

b) To assign a value to a variable

c)

c) To perform mathematical operations

d)

d) To define a function

5.

Which of the following is the correct syntax for assigning a value to a variable?

a)

a) var = 10

b)

b) 10 = var

c)

c) var : 10

d)

d) var <- 10

6.

What will happen if you try to assign a value to a keyword in Python?

a)

a) The value will be assigned successfully

b)

b) It will raise a syntax error

c)

c) The keyword will be converted to a variable

d)

d) The program will ignore the assignment

7.

1. What is the output of the following Python code?

str = "Hello, World!"

print(str[0])

a)

a) H

b)

b) e

c)

c) l

d)

d) Error

8.

3. What will the following Python code output?

str = "Python"

print(str[1:4])

a)

a) Pyt

b)

b) yth

c)

c) ytho

d)

d) Error

9.

What will be the output of the following Python code?

str = "Hello, World!"

print(str[7:])

a)

a) World!

b)

b) World

c)

c) , World

d)

d) Error

10.

Which of the following will return the square root of a number in Python?

a)

a) sqrt()

b)

b) math.sqrt()

c)

c) num.sqrt()

d)

d) num^0.5

11.

How can you convert a float number x to an integer in Python?

a)

a) int(x)

b)

b) float(x)

c)

c) round(x)

d)

d) convert(x)

12.

What is the primary purpose of the print() function in Python?

a)

a) To execute a loop

b)

b) To output data to the console

c)

c) To store data in a variable

d)

d) To create a new file

13.

What will be the result of trying to use a variable before it has been assigned a value in Python?

a)

b) It will raise a NameError

b)

d) It will raise a TypeError

c)

a) It will return None

d)

c) It will return an empty string

14.

Which of the following statements is true about lists in Python?

a)

a) Lists are immutable

b)

b) Lists can contain elements of different data types

c)

c) Lists cannot be nested

d)

d) Lists must have a fixed size

15.

How do you access the last element of a list named 'myList' in Python?

a)

a) myList[-1]

b)

b) myList[last]

c)

c) myList[len(myList)]

d)

d) myList[0]