NEW
Font size
WorksheetsPython Final 23
Total questions: 25
Worksheet time: 13mins
What is Python?
A snake
A programming language
A software
A type of food
What is used to define a block of code in Python?
Curly braces
Parentheses
Indentation
Quotation
How can you create a comment in Python?
Using the // symbol
Using the /*...*/ symbol
Using the # symbol
Using the -- symbol
Which Python function will you use to read input data from the user?
input()
raw_input()
read_input()
collect_input()
How do you create a variable "a" that is equal to 2 in Python?
int a = 2
var a = 2
a = 2
2 = a
Which of the following is not a valid Python data type?
List
Tuple
Dictionary
Table
How do you create a list in Python?
a = (1, 2, 3)
a = [1, 2, 3]
a = {1, 2, 3}
a = '1, 2, 3'
What will be the output of the following Python code snippet: print(10 > 9)
10
9
True
False
How can we generate random numbers in Python?
import random
import randomnumber
import random_number
import randint
How do you write a function in Python?
def function_name():
function_name():
function function_name():
func function_name():
What is the first index of a list in Python?
0
1
-1
Depends on the list
How do you check if a Python string, s, ends with a specific character, c?
How do you convert a string s to a list in Python?
list(s)
to_list(s)
convert_list(s)
s.list()
How do you get the length of a list, l, in Python?
length(l)
len(l)
l.length()
l.len()
What is the output of the following Python code: print("Hello, World!".lower())
hello, world!
Hello, World!
HELLO, WORLD!
None of the above
Which keyword is used for function declaration in Python?
func
function
define
def
What will be the output of the following code: print(len("Python"))
5
6
7
8
Which Python keyword indicates the start of a loop?
start
loop
begin
for
How do you create a dictionary in Python?
a = (1="one", 2="two", 3="three")
a = [1="one", 2="two", 3="three"]
a = {1: "one", 2: "two", 3: "three"}
a = '1="one", 2="two", 3="three"'
How do you create a tuple in Python?
a = (1, 2, 3)
a = [1, 2, 3]
a = {1, 2, 3}
a = '1, 2, 3'
What does the following Python statement do: import numpy as np
Imports all functions from the numpy library
Imports the numpy library and it can be referenced as np
Imports a specific function named numpy from the np library
Imports a specific function named np from the numpy library
What is the output of this statement: print("2" + "2")
4
22
"4"
"22"
What keyword is used to create a class in Python?
def
class
Class
Define
How can you get the type of variable or object x in Python?
get_type(x)
x.type()
type(x)
x.get_type()
