wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

christmas holiday happy activity python 2023

Total questions: 74

Worksheet time: 4hrs 59mins

Name
Class
Date
1.

Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?

a)

print('Hello World')

b)

print("Hello World")

c)

print('Hello World")

d)

print(""'Hello World'"")

2.

What is printed by the following statement?

print("P" not in "APCSP")

a)

True

b)

False

c)

Error

3.

What is printed by the following statement?

print("A" in "APCSP")

a)

True

b)

False

c)

Error

4.

Evaluate the following expression:

"dog" < "Dog"

a)

They are the same word

b)

True

c)

False

5.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

6.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

7.

Which operator returns True if target string is somewhere in the search string; otherwise it returns False.

a)

==

b)

!=

c)

in

d)

is

8.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

\l

b)

/

c)

\\n

d)

\n

9.

Which is the most appropriate data type for: "13th December"

a)

Float

b)

Boolean

c)

Integer

d)

String

10.

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

11.

What will the output be from the following code?

print("Hello world!\nHello world!")

a)

Hello world! Hello world!

b)

Hello world!

Hello world!

c)

SyntaxError

d)

Hello world!

12.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

13.

print("12"*3)

What would this print?

a)

121212

b)

36

c)

24

d)

12*3

14.

What will the output be from the following code?

print("Hello world!")

a)

SyntaxError

b)

Hello world!

c)

"Hello world!"

d)

print(Hello world!)

15.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

16.

Given the nested if-else below, what will be the value x when the code is executed successfully.

a)

0

b)

4

c)

2

d)

3

17.

This operator checks to see if one value is the same as the other value

a)

==

b)

!=

c)

>

d)

<

18.

What would be outputted here?

a)

Bigger than 2!

b)

Number is 5

c)

Bigger than 2!

Number is 5

d)

Nothing

19.

What will be outputted?

a)

number is bigger than 10

b)

nothing

c)

an error

d)

NUMBER IS BIGGER THAN 10

20.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

21.

Which keyword is used to display output in Python?

a)

output

b)

input

c)

print

d)

display

22.

Which keyword is used to take input from the user in Python?

a)

read

b)

scan

c)

input

d)

get

23.

What is the syntax to check if two values are not equal in Python?

a)

!==

b)

!=

c)

==

d)

<>

24.

What is the syntax to check if a value is greater than or equal to another value in Python?

a)

>

b)

>=

c)

<

d)

==

25.

What is the syntax to check if a value is greater than another value in Python?

a)

a < b

b)

a > b

c)

a >= b

d)

a == b

26.

Which logical operator is used to combine two conditions and returns True if both conditions are True?

a)

and

b)

xor

c)

not

d)

or

27.

Which logical operator is used to combine two conditions and returns True if at least one condition is True?

a)

xor

b)

not

c)

and

d)

or

28.

Which logical operator is used to negate a condition?

a)

not

b)

or

c)

and

d)

xor

29.

Which of the following correctly stores 'price' as a decimal number?

a)

price = int ( input ("Price: ")

b)

price = str( input ("Price: ")

c)

price = float ( input ("Price: ")

d)

price = input ("Price: ")

30.

Put this code into the right order

a)

age = int (input ("Enter age: "))

b)

nextYear = age + 1

c)

print ("Your age next year is: " + str(nextYear))

1)
2)
3)
31.

What is the first step to get started with Python?

a)

Install Python

b)

Learn Java

c)

Learn C++

d)

Buy a computer

32.

Organize the following data into the correct data type

Categorize the following

1

2

150

1025

1.0

1.2

0.0007

1810.0

2.0

500

"1"

'2.0'

'hello world'

"True"

'False'

True

False

Integer
Float
String
Boolean
33.

What is the better way to create a variable for storing your name: (a)   ​ ​ (b)   ​ (c)  

Choose from the below words
-
student_name
my_name
=
"Pikachu"
==
+=
-=
"hello world"
print
34.

What is the file extension for Python files?

a)

.py

b)

.java

c)

.cpp

d)

.html

35.

What is the main purpose of using a 'for' loop in Python?

a)

To iterate over a sequence of elements

b)

To define a function

c)

To create a class

d)

To perform arithmetic operations

36.

Which of the following is a valid way to comment in Python?

a)

// This is a comment

b)

# This is a comment

c)

/* This is a comment */

d)

%% This is a comment

37.

Given: students = ["Jamie", "Ellie", "Jason", "Clara"]

What is the correct way to use the for loop?

a)

for

b)

students

c)

in

d)

students

e)

:

1)
2)
3)
4)
5)
38.

What is the output of the following Python code?

print('Hello' + 'World')

a)

Hello World

b)

HelloWorld

c)

'Hello' + 'World'

d)

TypeError

39.

​ (a)   are containers used to store data in Python.

Choose from the below words
Variables
statements
execution
additions
substractions
40.
  1. To assign a value to a variable in Python, we use the ​ (a)   operator (​ (b)   ).

  2. For example: x ​ (c)   5 assigns the value 5 to the variable named "x".

Choose from the below words
=
+
-
*
/
addition
substraction
assignment
41.

This are the rules for naming variables in python:
-> Variable names must start with a letter or underscore.

  • -> Variable names can contain letters, numbers, and underscores.

  • -> Should not be a reserved keyword in Python.

What of the following names are invalid?

Categorize the following
  1. age

  1. student_grade

  1. name

  1. score_1

  1. totalMarks

  1. isPassed

  1. averageScore

2students

my name

variableName3

total_sales$

input

while

student-grade

Valid variable name
invalid variable name
42.

Whitespace in Python is used to improve code (a)   and organization.

Choose from the below words
readability
efficiency
functionality
43.

To remove whitespace from a string in Python, we can use the ​ (a)   function. For example, " Hello ".​ (b)   would remove the leading and trailing whitespace from the string and return "Hello".

Choose from the below words
strip()
print()
split()
upper()
44.

In python, which value is an empty list?

a)

{ }

b)

" "

c)

( )

d)

[ ]

45.

How would you assign the value 'hello' as the third value in a list stored in a variable named test? (Assume test contains [2, 4, 6, 8, 10].)

(a)  

46.

spam contains the list ['a', 'b', 'c', 'd']

What does spam[1] evaluate to?

a)

'a'

b)

'b'

c)

'c'

d)

'd'

47.

spam contains the list ['a', 'b', 'c', 'd']

What does spam[3] evaluate to?

a)

'a'

b)

'b'

c)

'c'

d)

'd'

48.

spam contains the list ['a', 'b', 'c', 'd']

What does spam[-1] evaluate to?

a)

'a'

b)

'b'

c)

'c'

d)

'd'

49.

spam contains the list ['a', 'b', 'c', 'd']

What does spam[0] evaluate to?

(I fixed this question. Pick the actual true answer)

a)

'a'

b)

'b'

c)

'c'

d)

'd'

50.

test contains the list ['banana', 3.14, True, 15]

What does test.index('banana') evaluate to?

(a)  

51.

test contains the list ['banana', 3.14, True, 15]

What does test.index(3.14) evaluate to?

(a)  

52.

test contains the list ['banana', 3.14, True, 15]

What does test.index(15) evaluate to?

(a)  

53.

test contains the list [3.14, 'cat', True, 'cat', 15]

What does len(test) evaluate to?

(a)  

54.

Match the following

a)

This method will add values only at the end of a list

1.

append( )

b)

This method can add values anywhere in a list

2.

insert( )

c)

This method can remove a value from a list

3.

remove( )

55.

spam = ['cat', 'dog', 'moose']

spam.reverse()

What will be the new list?

(a)  

56.

Which data types can be sorted with the sort( ) method? Pick all correct answers

a)

Integers

b)

Strings

c)

Booleans

57.

Which of the following create an empty dictionary called person?

a)

person = dict()

b)

person = ()

c)

person = []

d)

person = {}

58.
What data type is this?
quiz = {"Do you help out at home? ":"yes",        
"Do you beleive in Santa? ":"yes"
}
a)

list

b)

string

c)

dictionart

d)

dictionary

59.
is this code correct?
quiz = ("Do you help out at home? ":"yes"      }
a)
No
b)
Yes
c)
Both
60.

Which is the correct statement to delete a key-value pair from a dictionary called alien_11?

a)

alien_11.delete()

b)

alien_11.discard()

c)

alien_11.remove()

d)

del alien_11['keyName']

61.

________________method will returns number of key-value pairs in the given dictionary.

a)

len( )

b)

pop( )

c)

del( )

d)

keys( )

e)

values( )

62.

How much information can a dictionary store in python?

a)

Almost limitless amount of information.

b)

Less than 1 Kilobyte.

c)

A very limited amount of information.

d)

A infinite amount, a dictionary can contain all the data in the world and more.

63.

What is a string in Python?

a)

A string is what shoes have so they don’t fall off your feet.

b)

A string is the representation of numbers in Python.

c)

A string is a collection of items of any data type.

d)

A string is a series of characters.

64.

What is it a dictionary in python?

a)

It is a collection of key-value pairs.

b)

It is the representation of numbers in Python.

c)

It is a set of values associated with each other.

d)

It is a series of characters.

65.

What is it a key-value pair?

a)

It is a collection of key-value pairs.

b)

It is the representation of numbers in Python.

c)

It is a set of values associated with each other.

d)

It is a series of characters.

66.

What type of data can it be a key value?

a)

A key’s value can be a number, a string, a list, or even another dictionary.

b)

A key’s value only can be a number.

c)

A key’s value only can be a string.

d)

A key’s value only can be a list.

67.

How many key-value pairs does the following dictionary have?

 

alien_0 = {'color': 'green', 'points': 5, 'power': 50}

(a)  

68.

Can you add new key-value pairs to dictionaries?

a)

Yes

b)

No

69.

Does python allow you to loop through a dictionary?

a)

Yes

b)

No

70.

What method can we use to print all the key-value pairs of a dictionary as a list?

a)

items()

b)

keys()

c)

values()

d)

set()

71.

What method can we use to loop through all the keys of a dictionary?

a)

items()

b)

keys()

c)

values()

d)

set()

72.

What method can we use to loop through all the values of a dictionary?

a)

items()

b)

keys()

c)

values()

d)

set()

73.

What function can you use to loop through all the values of a dictionary avoiding duplicated values?

a)

items()

b)

keys()

c)

values()

d)

set()

74.

What is nesting in python?

a)

It is a natural instinct experienced by many expecting mothers, most commonly in the last trimester.

b)

Are dynamic structures, and you can add new key-value pairs

to a dictionary at any time.

c)

It is to store multiple dictionaries in a list, or a list of

items as a value in a dictionary.