wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Game of Codes Workshop: Comprehensive Reading Material

Total questions: 64

Worksheet time: 32mins

Name
Class
Date
1.

What is Python? Fill in the blank: Python is a ________-level programming language with clear syntax, widely used in academia and industry for its versatility and readability.

a)

high

b)

low

c)

machine

d)

assembly

2.

In Python, variables are containers for storing ________ values.

a)

data

b)

functions

c)

loops

d)

modules

3.

Comments are used to explain code. Comments are ignored by Python when code runs. Which symbol is used for a single line comment in Python?

a)

//

b)

#

c)

;;

4.

Triple single inverted commas (''' ''') are used for multi line comments in Python.

a)

True

b)

False

5.

Fill in the blank: The ________ function is used to display output in Python.

a)

print()

b)

display()

c)

show()

d)

output()

6.

What is the value of the variable 'x' if it is defined as x = 10?

a)

10

b)

5

c)

0

d)

20

7.

Which of the following is a float value?

a)

10

b)

3.14

c)

'Hello'

d)

True

8.

What is the data type of the variable s = 'Hello'?

a)

String

b)

Integer

c)

Boolean

d)

Float

9.

Which of the following is a boolean value?

a)

10

b)

3.14

c)

'Hello'

d)

True

10.

What is the output of the following code? numbers = [1, 2, 3, 4] print(numbers)

a)

[1, 2, 3, 4]

b)

1 2 3 4

c)

numbers

d)

[1,2,3,4] (without spaces)

11.

What is the output of the following code? coords = (10, 20) print(coords)

a)

(10, 20)

b)

10 20

c)

[10, 20]

d)

(10; 20)

12.

What is the output of the following code? student = {"name": "Alice", "age": 20} print(student)

a)

{'name': 'Alice', 'age': 20}

b)

{"name": "Alice", "age": 20}

c)

[('name', 'Alice'), ('age', 20)]

d)

name: Alice, age: 20

13.

What is the output of the following code? unique_nums = {1, 2, 3} print(unique_nums)

a)

{1, 2, 3}

b)

[1, 2, 3]

c)

(1, 2, 3)

d)

{1: 2, 3: 4}

14.

Which operator is used for addition in Python?

a)

-

b)

*

c)

+

d)

/

15.

Which operator is used for exponentiation in Python?

a)

**

b)

//

c)

%

d)

/

16.

What is the output of the following code? a = 4 b = 6 print(a + b)

a)

10

b)

12

c)

8

d)

46

17.

What is the output of the following code? a = 10 b = 3 print(a ** b)

a)

1000

b)

30

c)

13

d)

300

18.

What is the output of the following code? a = 10 b = 3 print(a > b)

a)

True

b)

False

c)

None

d)

10

19.

What is the output of the following code? a = 10 b = 3 print(a != b)

a)

True

b)

False

c)

None

d)

10

20.

Which statement executes a block of code only if a given condition is true?

a)

if statement

b)

for statement

c)

while statement

d)

print statement

21.

Which statement allows for multiple conditions to be checked sequentially?

a)

if statement

b)

if-else statement

c)

if-else-elif statement

d)

while statement

22.

Which loop repeats as long as a condition is True?

a)

for loop

b)

while loop

c)

if loop

d)

print loop

23.

What is the output of the following code? x = 745 if x > 0: print("Positive") elif x == 0: print("Zero") else: print("Negative")

a)

Positive

b)

Zero

c)

Negative

d)

None of the above

24.

What is the output of the following code? countries = ["Japan", "USA", "UK"] for country in countries: print(country)

a)

Japan USA UK

b)

Japan, USA, UK

c)

UK USA Japan

d)

Japan USA UK

25.

What is the output of the following code? for i in range(4): print(i)

a)

0 1 2 3

b)

1 2 3 4

c)

0 1 2 3 4

d)

1 2 3

26.

What is the output of the following code? count = 0 while count < 5: print(count) count += 1

a)

0 1 2 3 4

b)

1 2 3 4 5

c)

0 1 2 3 4 5

d)

1 2 3 4

27.

What is a function in Python?

a)

A variable that stores data

b)

A reusable block of code that performs a specific task

c)

A type of loop

d)

A Python file

28.

Fill in the blank: The keyword used to define a function in Python is _____

a)

def

b)

func

c)

define

d)

function

29.

What is the output of the following code? def greet(): print("Welcome to Game of Codes!") greet()

a)

Welcome to Game of Codes!

b)

Hello World!

c)

Syntax Error

d)

None

30.

What is a module in Python?

a)

A loop

b)

A Python file containing definitions and statements

c)

A variable

d)

A function

31.

What is the output of the following code? import math print(math.sqrt(16))

a)

2.0

b)

4.0

c)

8.0

d)

16.0

32.

NumPy is a Python library for _____

a)

Web development

b)

Numerical computing

c)

String manipulation

d)

File handling

33.

Fill in the blank: The number of dimensions of a NumPy array is called the _____ of the array.

a)

rank

b)

shape

c)

size

d)

axis

34.

What is the output of the following code? a = np.array([1, 2, 3]) print(a)

a)

[1, 2, 3]

b)

(1, 2, 3)

c)

{1, 2, 3}

d)

1 2 3

35.

What is a Series in Pandas?

a)

One-dimensional data (like a column)

b)

Two-dimensional data (like a table)

c)

Three-dimensional data

d)

None of the above

36.

What is a DataFrame in Pandas?

a)

One-dimensional data (like a column)

b)

Two-dimensional data (like a table)

c)

Three-dimensional data

d)

None of the above

37.

What will be the output of the following code? import numpy as np c = np.array([11, 22, 33, 44, 55]) print(c[0])

a)

11

b)

22

c)

33

d)

44

38.

What will be the output of the following code? import numpy as np c = np.array([11, 22, 33, 44, 55]) print(c[-1])

a)

55

b)

44

c)

11

d)

33

39.

What will be the output of the following code? import numpy as np d = np.array([[1,2,3], [4,5,6], [7,8,9]]) print(d[0, 1])

a)

2

b)

1

c)

3

d)

5

40.

What will be the output of the following code? import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(a + b)

a)

[5 7 9]

b)

[4 10 18]

c)

[1 2 3 4 5 6]

d)

[3 3 3]

41.

What will be the output of the following code? import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(a * 2)

a)

[2 4 6]

b)

[5 7 9]

c)

[1 2 3 4 5 6]

d)

[8 10 12]

42.

What will be the output of the following code? import pandas as pd s = pd.Series([1, 2, 3, 4, 5]) print(s)

a)

0 1 1 2 2 3 3 4 4 5 dtype: int64

b)

1 1 2 2 3 3 4 4 5 5 dtype: int64

c)

0 1 1 2 2 3 3 4 4 5 dtype: float64

d)

0 5 1 4 2 3 3 2 4 1 dtype: int64

43.

What will be the output of the following code? import pandas as pd mydata = { 'Country': ['India', 'USA', 'Japan', 'Switzerland'], 'CountryCode': [91, 1, 81, 268], 'Currency': ['Rupee', 'Dollar', 'Yen', 'Franc'] } df = pd.DataFrame(mydata) print(df)

a)

Country CountryCode Currency 0 India 91 Rupee 1 USA 1 Dollar 2 Japan 81 Yen 3 Switzerland 268 Franc

b)

Country CountryCode Currency 0 India 91 Dollar 1 USA 1 Rupee 2 Japan 81 Yen 3 Switzerland 268 Franc

c)

Country CountryCode Currency 0 India 91 Rupee 1 USA 1 Franc 2 Japan 81 Dollar 3 Switzerland 268 Yen

d)

Country CountryCode Currency 0 Switzerland 268 Franc 1 Japan 81 Yen 2 USA 1 Dollar 3 India 91 Rupee

44.

Which of the following code snippets will select the 'Country' column from the DataFrame df?

a)

df['Country']

b)

df.Country

c)

df.loc['Country']

d)

df.iloc['Country']

45.

Fill in the blank: The currency of India is _______.

a)

Rupee

b)

Dollar

c)

Yen

d)

Euro

46.

Fill in the blank: The country code for Japan is _______.

a)

81

b)

44

c)

49

d)

86

47.

Fill in the blank: The currency of Switzerland is _______.

a)

Franc

b)

Euro

c)

Dollar

d)

Pound

48.

Which country uses the Dirham as its currency?

a)

India

b)

UAE

c)

Japan

d)

Switzerland

49.

Which Python library is used to make graphs, charts, and plots from data?

a)

NumPy

b)

Pandas

c)

Matplotlib

d)

Seaborn

50.

In the given code, what does the function plt.show() do?

a)

plt.show() displays the plot window.

b)

plt.show() saves the plot as an image file.

c)

plt.show() clears the current plot.

d)

plt.show() adds a title to the plot.

51.

What is the title of the plot shown in the image?

a)

Simple Line Plot

b)

Bar Chart

c)

Scatter Plot

d)

Pie Chart

52.

In the code, what does plt.xlabel('X-axis') do?

a)

It sets the label for the X-axis of the plot.

b)

It sets the title of the plot.

c)

It sets the label for the Y-axis of the plot.

d)

It changes the color of the X-axis.

53.

What type of plot is shown in the 'Customized Plot' figure?

a)

Bar Chart

b)

Line Plot

c)

Scatter Plot

d)

Pie Chart

54.

Based on the bar chart shown, what is the value for category 'C'?

a)

15

b)

10

c)

20

d)

25

55.

Which color is used for the bars in the bar chart according to the code?

a)

Blue

b)

Orange

c)

Red

d)

Green

56.

In the scatter plot code, what marker is used for the points?

a)

o

b)

*

c)

x

d)

s

57.

What is the y-value corresponding to x = 10 in the scatter plot?

a)

20

b)

10

c)

15

d)

25

58.

What does the following code do? plt.xlabel('Categories') plt.ylabel('Values')

a)

It sets the x-axis label to 'Categories' and the y-axis label to 'Values'.

b)

It creates a bar chart with categories and values.

c)

It plots a line graph with categories on the x-axis and values on the y-axis.

d)

It saves the plot as an image file named 'Categories_Values.png'.

59.

Refer to the code snippet below: '''1 '''Reading and Writing Files:''' 2 3 with open('data.txt', 'r') as file: 4 content = file.read() 5 print(content) ''' What is the purpose of the code snippet shown above?

a)

To write data to a file

b)

To read data from a file and print it

c)

To delete a file

d)

To create a new file

60.

Fill in the blank: The mode used to open the file in the code snippet is '__'.

a)

r

b)

w

c)

a

d)

rb

61.

Which of the following is an application of Python in scientific computing?

a)

Data cleaning

b)

Simulations and data analysis

c)

Web development

d)

Report generation

62.

Which of the following is an example of Python use in data science?

a)

Automating report generation

b)

Visualizing trends in experimental data

c)

Coding quiz

d)

Web development

63.

Which of the following is NOT listed as a resource for further learning Python?

a)

Python Official Documentation

b)

NumPy Documentation

c)

JavaScript Documentation

d)

Pandas Documentation

64.

Name one recommended book for learning Python mentioned in the worksheet.

a)

'Automate the Boring Stuff with Python' by Al Sweigart

b)

'The C Programming Language' by Brian Kernighan and Dennis Ritchie

c)

'Java: The Complete Reference' by Herbert Schildt

d)

'Head First JavaScript Programming' by Eric Freeman and Elisabeth Robson