wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 118

Worksheet time: 3615secs

Name
Class
Date
1.
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!
2.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
3.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
4.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
5.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
6.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

7.
What is python named after
a)
The snake
b)
Television show called Monty Python
8.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
9.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
10.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
11.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
12.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
13.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
14.
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
15.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
16.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
17.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
18.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
19.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
20.

people = ["John", "Rob", "Bob"]

print (people[4])

what would this result be?

a)
John
b)
Rob
c)
Bob
d)
Error
21.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
22.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

23.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
24.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
25.

If you want to create an empty list called colours in Python, which of the following is correct?

a)

colours = [ ]

b)

colours = ( )

c)

colours = { }

d)

colours = <>

26.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
27.
What is the position of the name "Robert" in the following list:
a)
0
b)
1
c)
2
d)
3
28.
What does the APPEND procedure do in the following code:
a)
Adds Liverpool to the beginning of the list
b)
Replaces Bristol with Liverpool
c)
Replaces Manchester with Liverpool
d)
Adds Liverpool to the end of the list
29.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
30.

Each item in a list has an index. What is the first index in a Python list?

a)

0

b)

1

c)

a

d)

A

31.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
32.
What output will this code produce?
a)
3
b)
20
c)
25
d)
17
33.
What output will this code produce?
a)
1
b)
3
c)
2
d)
4
34.

What will the output be from the following code?

print(3+4)

a)

3+4

b)

7

c)

SyntaxError

d)

print(3+4)

35.
print("12"*3)
What would this print?
a)
36
b)
121212
c)
24
d)
12*3
36.

What will the output be from the following Python code?

Print("Hello world!")

a)

NameError

b)

Hello world!

c)

"Hello world"

d)

Print(Hello world!)

37.

What will the output be from the following Python code?

print(9/3)

a)

3

b)

3.0

c)

9/3

d)

SyntaxError

38.

What will the output be from the following Python code?

print(Hello world!)

a)

Hello world!

b)

SyntaxError

c)

Hello world

d)

print(Hello world!)

39.
A location in memory used to store data that can be changed.
a)
Constant
b)
Value
c)
Variable
d)
Iteration
40.

What is the Python built-in function to converts a number to a string?

a)

str()

b)

int()

c)

parseInt()

d)

convert

41.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
42.

Which of these is correct Python conditional statement?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":

43.

which library we import if we want to draw chart

a)

numpy

b)

matplotlib

c)

pandas

44.

to add a title in the chart we use the function

a)

title("title of the chart")

b)

plt.title("title of the chart")

c)

plt.title(title of the chart)

45.

Which of the codes below should we use to rotate the data ticks on x-axis?

a)

plt.xticks(rotation=30)

b)

plt.ylabel(rotation=30)

c)

plt.yticks(rotation=30)

d)

plt.xlabel(rotation=30)

46.

Which code should we use to display our graphs?

a)

plt.display()

b)

plt.graph()

c)

plt.show()

d)

plt.chart()

47.

pyplot is also a python library.

a)

False

b)

True

48.

This is an example of a ___________.

a)

Scatter Chart

b)

Line Graph

c)

Bar Graph

d)

Pie Chart

49.

We can use matplotlib without installing the library.

a)

True

b)

False

50.

The maximum number that you can assign for the color is ____.

a)

4

b)

3

c)

2

d)

1

51.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
52.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
53.

Python language was developed in what year?

a)

1985

b)

2001

c)

1991

d)

1820

54.

Is python an interpreter or compiler programming language?

a)

Compiler

b)

Interpreter

55.

Python is uses braces to block off code

a)

True

b)

False

56.

Python uses indentation to block code into chunks

a)

True

b)

False

57.

Python correct naming convention for constants is?

a)

firstName

b)

First_Name

c)

FIRST_NAME

d)

firstname

58.

Python correct naming convention for variables is?

a)

new_user25

b)

NewUser25

c)

25_new_user

d)

25NewUser

e)

NEWUSER25

59.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

60.

What result will display in the shell if 15 and 20 is entered by the user?

a)

"num1 + num2"

b)

1520

c)

35

61.

What datatype will the answer be if the user enters 15 and 30?

a)

Integer

b)

String

c)

Boolean

d)

Float

62.

Which one will display when this code is run?

a)
b)
c)
d)
63.

What does these 4 colour boxes on extreme right side called

a)

Title

b)

Legend

c)

Heading

d)

Label

64.

Plot can be saved in a pdf form

a)

True

b)

False

65.

Matplotlib is a python interface.

a)

True

b)

False

66.

The most popular data visualization library in python is _______.

a)

pip

b)

matinfolib

c)

matplotlib

d)

matpiplib

67.

Markers are data points in the graph?

a)

True

b)

False

68.

______________________ are drawn with respect to the histogram created?

a)

bar plot

b)

Frequency polygon

c)

box plot

d)

none

69.

___________plot is also described as five-number summery plot.

a)

Histogram

b)

box plot

c)

frequency polygon

d)

scatter plot

70.

Which of the following methods should be employed in the code to display a plot?

a)

Display()

b)

Show()

c)

Execute()

d)

Plot()

71.

Which Python Package is used for 2D graphics?

a)

matplotlib.pyplot

b)

matplotlib.pip

c)

matplotlib.numpy

d)

matplotlib.plt

72.

________________function is used to create a horizontal bar chart.

a)

barchart()

b)

barh()

c)

bar()

d)

None of the above

73.

In computer science, information and facts observed and collected are known as _______________ .

a)

Desktop

b)

Computer

c)

Data

d)

Hard Disk

74.

The process of data representation through plots and graphs is called ____________.

a)

Data Science

b)

Data Visualization

c)

Data

d)

Drawing

75.

This is an example of a ________________ plot.

a)

Column

b)

Area

c)

Scatter

d)

Line

76.

Choose the correct option

a)

plt.xlabel("Tree Growth")

b)

plt.ylabel("Tree Growth")

c)

plt.color("Tree Growth")

d)

plt.title("Tree Growth")

77.

Choose the correct option.

a)

plt.xlabel("Year")

b)

plt.ylabel("Year")

c)

plt.title("Year")

d)

plt.DataFrame("Year")

78.

Choose the correct option.

a)

plt.title("Feet")

b)

plt.ylabel("Feet")

c)

plt.xlabel("Feet")

d)

plt.Data("Feet")

79.

It is better to use line plots when the data is related to time, like growth over years.

a)

True

b)

False

80.

__________________ function is used to create line plot in python.

a)

plot()

b)

line()

c)

scatter()

d)

dataframe()

81.

__________________ function is used to create Scatter plot in python.

a)

plot()

b)

line()

c)

scatter()

d)

dataframe()

82.

The bigger the data collection the better understanding of Data.

a)

True

b)

False

83.

This is an example of a ________________ plot.

a)

Column

b)

Area

c)

Scatter

d)

Line

84.

The process of studying data is called ________________

a)

Data Analysis

b)

Data Collection

c)

Data Visualization

85.

The library that used to create graphs or plots in Python is_____________

a)

DataFrame

b)

Pandas

c)

Matplotlib

86.

What is Data Visualization?

a)

is what allows your phone to get online when you're away from Wi-Fi.

b)

is the graphical representation of information and data.

87.

What is line plot?

a)

type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data.

b)

type of chart which displays information as a series of data points called 'markers' connected by straight line segments.

88.

Scatter plot is: type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data.

a)

False

b)

True

89.

There are how many types of line graphs?

a)

4 types

b)

6 types

c)

3 types

90.

Full form of API

a)

Application Process Interchange

b)

Application Programs Interchange

c)

Application Process Interface

d)

Application Programming Interface

91.

Connector Library to connect MySQL with Python IDLE is

a)

pymysql

b)

mysql.connector

c)

both a and b

d)

none of these

92.

import mysql.connector as mys


mydb = mys.connect( host="localhost", user="root",

password="root"

)


mycursor = mydb.cursor()


mycursor.execute("CREATE DATABASE KVSEC3")

AFTER EXECUTING THE ABOVE CODE. What will be done

(a)  

93.

To display all the databases of MySQL with the help of cursor mycursor , command will be

a)

mycursor.execute("SHOW DATABASES")

b)

mycursor.execute("DESC DATABASES")

c)

mycursor.executes("SHOW DATABASES")

d)

mycursor.execute("SHOW ALL DATABASES")

94.

Correct the error if any

mycursor = mydb.cursor()


mycursor.execute("CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))")

a)

mycursor.execute('CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))')

b)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55))')

c)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55));")

d)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR55))")

95.

After inserting the data we need to issue

a)

rollback

b)

set autocommit

c)

mycur.commit(1)

d)

mycur.commit()

96.

To close a connection (CON) we Use

(a)  

97.

What does CSV stand for?

a)

Cursor Separated Variables

b)

Comma Separated Values

c)

Cursor Separated Values

d)

Cursor Separated Version

98.

Which module is used for working with CSV files in Python?

a)

random

b)

statistics

c)

csv

d)

math

99.

Pandas deals with following data structures

a)

Series

b)

Series and Data Frames

c)

Series, DataFrames and Panel

d)

None of Above

100.

Best way to import the pandas module in your program ?

a)

1.import pandas

b)

2.import pandas as pd

c)

3.from pandas import *

d)

4.All of the above

101.

DataFrame in pandas is

a)

1. dimensional array

b)

2. dimensional array

c)

3.dimensional array

d)

4.None of the above

102.

All pandas data structures are ___ mutable but not always _______mutable.

a)

a) size, value

b)

b) semantic, size

c)

c) value, size

d)

d) none of the mentioned

103.

Which of the following object you get after reading CSV file?

a)

a) DataFrame

b)

b) Character Vector

c)

c) Panel

d)

d) All of the mentioned

104.

Which of the following library is similar to Pandas?

a)

a) NumPy

b)

b) RPy

c)

c) SciPy

d)

d) None of the mentioned

105.

Which is not a feature of series

a)

Homogeneous data

b)

Immutable size

c)

Mutable data

d)

Multiple rows

106.

Series can be created from

a)

Array

b)

Dictionary

c)

Scaler value

d)

All of them

107.

Full form of CSV file is

a)

Comma Separated Vault

b)

Comma Separated Value

c)

Common Separated Value

d)

Common System Value

108.

Not a function of Dataframe

a)

Head()

b)

Tail()

c)

loc()

d)

multi()

109.

Dataframe can contain multiple series

a)

True

b)

False

110.

Which function from the options given below can read the dataset from a large text file?

a)

read_json

b)

read_pickle

c)

read_hdf

d)

read_csv

111.

Which of the following can be used to make a Dataframe?

a)

Series

b)

DataFrame

c)

Structured ndarray

d)

All of the above

112.

Which is the correct Pandas syntax to read in a csv file and assign it to a DataFrame df?

a)

df = read_csv('file.csv')

b)

df = read('file.csv', type = 'csv')

c)

df = pd.read_csv('file.csv')

d)

df = with open('file.csv') as pd.DataFrame

113.

Type the syntax that returns the top 5 rows in DataFrame df with the native Pandas function (not slicing):

(a)  

114.

Among the following functions, which one can be used to combine dataframes when they have similar structure.

a)

combine_first

b)

concat()

c)

merge()

115.

For the concat(), if the axis=1, it will join the dataframes ...............

a)

vertically

b)

horizontally

116.

Which function can be used to combine dataframes based on common fields?

a)

merge()

b)

combine_first()

c)

concat()

117.

Which function views dataframe in the form of vertical subset ie column wise?

a)

iterrows()

b)

iteritems()

118.

Which of the functions can be used to delete column/row from a DataFrame?

a)

pop()

b)

at()

c)

drop()

d)

iloc()