Font size
Worksheetsэнгглиш 1
Total questions: 120
Worksheet time: 1hrs 11mins
What symbol is used to indicate a comment in Python?
//
b) /* */
d) --
c) #
How to declare a variable in Python?
b) x = 10
c) int x = 10
a) var x = 10
d) declare x = 10
Which operator is used to raise a number to a power?
a) ^
b) **
c) *
d) ^^
How to display text on screen in Python?
a) display ("Hello")
c) print ("Hello")
d) printf ("Hello")
b) echo "Hello"
How to check the type of a variable in Python?
a) typeOf (x)
b) typeof (x)
d) checkType (x)
c) type (x)
What is a list in Python?
a) Ordered collection of elements
c) Key-value collection
b) Unordered collection of elements
d) Data type for storing a single value
list ()
a) list ()
c) empty_list ()
d) new_list ()
b) []
1. How to get the length of a list?
c) len ( list )
b) size ( list )
a) list.size ()
d) length ( list )
1. Which method is used to add an element to the end of a list?
a) add ()
c) append ()
d) push ()
b) insert ()
1. How to remove an element from a list by index?
c) del list [ index ]
b) delete ( index )
a) remove ( index )
d) pop ( index )
11. Which function is used to enter data from the keyboard?
b) read ()
a) input ()
c) get ()
d) scan ()
11. What data type is used to store integers?
a) long
a) integer
a) number
a) int
11. How to create a condition in Python?
a) condition {
a) when condition :
a) if condition :
a) if ( condition )
11. Which operators are not used to compare values?
a) <>
a) !=
a) **
a) ==
11. Which of the following data types are mutable ?
a) lista) list
a) str
a) float
a) int
11. What symbols are used to create a block of code in Python?
a) ()
a) <>
a) {}
a) []
11. Which of the following methods is not used to manipulate strings?
a) upper ()
a) split ()
a) append ()
a) title( )
11. What loop is used to iterate through the elements in a list?
a) while
a) repeat
a) for-in
a) loop
11. How to convert a string to an integer?
a) toInt ( string )
a) parse ( int , string )
a) str2int( string )
a) int ( string )
11. How to display list elements in reverse order?
a) reverse ( list )
a) flip ( list )
a) list.reverse ()
a) reverseList ( list )
11. What is the result of performing the operation 3 + 5 * 2?
a) 16
a) 13
a) eleven
a) 26
11. How to create a list in Python?
a) array = (1, 2, 3)
a) set = {1, 2, 3}
a) list = [1, 2, 3]
a) tuple = (1, 2, 3)
11. How to get the length of a list?
a) len ( list )
a) count ( list )
a) length ( list )
a) size ( list )
11. Which method is used to add an element to the end of a list?
a) list.append (4)
a) list.insert (4)
a) list.add (4)
a) list.extend (4)
11. What does an if statement do in Python?
a) Creates a loop
a) Executes a block of code if the condition is true
a) Prints text on the screen
a) Defines a function
11. What is the result of running range (3) ?
a) [0, 1, 2]
a) [1, 2, 3]
a) (1, 2, 3)
a) (0, 1, 2)
11. How to read user input from keyboard?
a) keyboard ()
a) read ()
a) get ()
a) input ()
11. Which operator is used to concatenate two strings?
a) &
a) *
a) +
a) /
11. Which operator is used to test equality in Python?
a) !=
a) <
a) =
a) ==
11. Which loop is used to execute a block of code a certain number of times?
B. for
A. if
C. while
D. loop
11. What is "pseudocode"?
. Real Python Code
C. Mark for comments in code
B. A language for describing algorithms, close to structured programming
Programming language
11. How to create an "if x is greater than 10" condition in Python?
if x => 10:
D. if x < 10:
C. if x = 10:
A. if x > 10:
11. How to add a check for three conditions in Python?
A. if x > 0 and x < 10:
B. if x > 0 or x < 10:
C. if x > 0, x < 10:
D. if x > 0 && x < 10:
11. How to create a list ( list ) in Python?
D.list (1 2 3) ;D.list (1 2 3) ;
C. list (1, 2, 3);
B. list = [1, 2, 3];
A. list = {1, 2, 3};
11. What is the "efficiency" of an algorithm?
A. Algorithm execution speed
C. Text color in comments
D. Program File Size
B. Number of lines of code
11. What is an index in Python?
A. Phone book number
C. Character Encoding
B. The ordinal number of the element in the sequence
D. Unique variable identifier
Which loop is used to execute a block of code while a condition is true?
A. if
D. loop
C. while
B. for
11. What will be the result of running the following code:
x = 7
if x < 5: print ("Not enough")
else : print ("A lot")
B. "A lot"
A. "Not enough"
D. Runtime error
11. What is "breaking" a loop?
a. Error in loop
a. Premature termination of the cycle
a. Print an error message
a. Changing a variable in a loop
11. What is the result of running this code: 5 + 3 * 2?
a. 16
a. 26
a. 10
a. eleven
11. How to break the loop if x reaches the value 5?
a. break if x == 5
a. terminate x == 5
a. if x == 5: break
a. stop when x == 5
11. What does a while loop do ?
Executes a block of code a specified number of times
a. Starts an infinite loop
a. Loops through the elements of a sequence
Executes a block of code while the condition is true
11. int variable :
a) boolean variable
character string
a) integer variable
a) real variable
11. float variable :
a) real variable
a) boolean variable
a) character string
a) integer variable
11. Variable str :
a) real variable
a) integer variable
a) boolean variable
a) character string
11. bool variable :
a) character string
a) real variable
a) integer variable
a) boolean variable
11. Variable names cannot include:
a) Russian letters
a) Spaces
a) Letters
a) Numbers
11. What names are incorrect in PYTHON
a) G_M
a) ABC
a) 41N
a) Game2
11. An algorithm in which actions are performed depending on the truth of a condition is called:
a) linear
a) cyclical
a) branching
a) vector
11. An algorithm in which actions are performed sequentially one after another is called
a) vector
a) linear
a) branching
a) cyclical
11. An algorithm in which a certain sequence of actions is performed repeatedly is called
a) linear
a) vector
a) branching
a) cyclical
11. What data type in Python represents integers?
a) complex
a) bool.
a) int
a) float
Which of the following number literals are of type float ?
a) 1.7+4.3j
a) 88
a) -4
a) 5.0
11. What will be displayed on the screen as a result of executing the conditional code? x = 5 y = 2 z = x // y print ( z )
a) 2
a) 3
a) 2.5
a) error.
11. What will be printed on the screen as a result of executing the print ( 4 + 3.0) statement?
a) 7
a) error
a) 4+3.0
a) 7.0
11. What will be displayed on the screen as a result of executing the conditional code? x = 5 y = 2 z = x % y print ( z )
a) error.
4
a) 1
a) 3
11. What will be displayed on the screen as a result of executing the conditional code? x = 5 x += x – x print ( x )
a) 0
a) error.
b) 10
a) 5
What will be displayed on the screen as a result of executing the conditional code? x = 3 y = 3.0 z = '3' print ( x + y + z )
a) error.
a) 10
a) 0
a) 5
11. What will be printed on the screen as a result of executing the print ( 5**(5 - 2)) statement?
a) Error
a) 15
a) 45.0
a) 125
11. Which operator is used to get the remainder of division in Python?
a) %
a) //
a) **
a) /
11. What will be displayed on the screen as a result of executing the conditional code? x = '7' y = '3' z = x + y print ( z )
a) 7+3
a) Error
a) 10
a) 73
11. What does the len ( ) function return when passed a string?
a) word count
a) number of bytes
a) Characters
a) error
11. How to add an elem element to the end of a li list ?
a) li.append ( elem )
a) li += [ elem ]
a) li.insert ( len (li), elem )
a) li.extend ([ elem ])
How to remove the element elem from a list li by its index i?
a) li.pop ( i )
a) li. clear ( )
a) li.append ( i )
a) li.remove ( elem )
Dan list li = ['a', 'b', 'cd', 'e', 'f']. List the instructions that will display the symbol d.
a) print( li[ -3][1])
a) print( li[ 2][2])
a) print( li[ 3])
a) print( li[ 2][1])
11. What data type represents tuples in Python?
set
a) dict
a) list
a) tuple
11. What will be displayed on the screen as a result of executing the conditional code? d = {1: 'a', '2': ['b', {'c': 3}], (5, '6'): ('f', 'g' )} print ( len ( d ))
4
3
10
2
11. The algorithm is:
11. The algorithm is:a) a system of rules that describes the sequence of actions that must be performed to solve a problem
a program designed to create and process graphic information
a) step-by-step description of the sequence of actions that must be performed to solve the problem;
a) description of the properties and patterns of behavior of objects that are essential for the task at hand, ensuring its solution;
11. How many basic algorithm structures do you know?
2
5
3
4
One of the properties of the algorithm:
a) efficiency
a) operationality
a) mass character
a) cyclicality
11. The algorithm must consist of separate steps, as the property is called:
a) About ambiguity
a) Mass character
a) Limb
a) Discreteness
1. Jupyter Notebooks have code cells and markdown cells.
False
TRUE
1. Which is a valid Python code comment?
· (comment) warnings can be placed in comments.
· // comments make code easier to update.
· # use comments to describe the function of code.
· [comment] comments can provide use instructions for other developers.
1. Choose the correct statement
D. New variables always start out as zero.
The same variable in Python can be represented in either upper or lower case
A. Variables only represent strings in Python.
C. Variables in Python can be initialized using the equals sign (=).
1. The type() function is used to change from one data type to another
FALSE
TRUE
What does type("Hello World!") return?
all of the below
int
str
float
1. What does the Python code: score = 3 + "45" result in?
48
TypeError
345
type()
1. def show_name():
print("Tobias Ledford")
Which code calls the function in the above code?
1. def add_num(num_1 = 10):
print(num_1 + num_1)
Choose the correct output of calling the above function using the following code:
add_num()
0
20
10
· An Error
1. def low_case(words_in):
return words_in.lower()
Choose the correct output of calling the function above using the following code:
words_lower = low_case("Return THIS lower")
print(words_lower)
· "return this lower"
· An Error
· "Return THIS lower"
· No Output
1.
if hot_plate:
print("Be careful, hot plate!")
else:
print("The plate is ready.")
What is the output from running the above code?
· "Be careful, hot plate!"
· "True"
· "The plate is ready."
· NameError
1. vehicle_type = "Truck"
if vehicle_type.upper().startswith("P"):
print(vehicle_type, 'starts with "P"')
else:
print(vehicle_type, 'does not start with "P"')
What is the output from running the above code?
· "False"
· "True"
· "Truck starts with "P""
· "Truck does not start with "P"''
1. if True:
if False:
print("Banana")
else:
print("Apple")
else:
if True:
print("Dates")
else:
print("Corn")
What is the output of the above code?
Apple
Banana
Corn
Dates
1. x = 0
while True:
if x < 10:
print('run forever')
x += 1
else:
break
What is the output from running the above code most like?
· "run forever"
· No output
· "run forever" (10 times)
· "run forever" (9 times)
1. Which statement best describes a String in Python/Computer Science?
· object existing in four dimensions
· sequence of characters
· computer keyboard
· series of 1's and 0's
1. Choose the statement that will print the letter "d", given the variable declaration word = "windows"
· print(word[3])
· print(word[-2])
· print(word[2])
· print(word[-1])
1. Which choice will print the word "tac", given the following variable declaration?
word = "cat"
· print(word[2:1:0])
· print(word[::1])
· print(word[0:1:2])
· print(word[::-1])
1. Which choice best represents the output of the following code?
student_name = "iteration"
count = 0
for letter in student_name:
if letter.lower() == "e":
print(count)
count += 1
· "-4"
· "3"
· "-5"
· "2"
1. Which string method returns an index of first character or substring matches?
· while
· .find()
· .count()
· .isalpha()
1. Which choice is a valid Python code to store the length of the given string variable 'word' below in 'x'?
word = "Python"
· for x in length of word
· x.length(word)
· x = len(word)
· x = word.len()
1. What data type is this?
quiz = {"Do you help out at home? ":"yes",
"Do you beleive in Santa? ":"yes"}
· string
· dictionary
· list
· tuple
1. Which symbol surrounds a dictionary?
· :
· {
· [
· (
1. What is the output of this code?
dl={1:10, 2:20, 3:30, 4:40}
d2={5:50, 6:60, 7:70}
dl.update (d2)
print (dl)
· {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60, 7: 70}
· [1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60, 7: 70]
· [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50)]
· {1:10, 2: 20, 4: 40, 5: 50, 6: 60, 7: 70}
1. What is the output of the code?
dl={1:10, 2:20,3:30, 4:40, 5:50, 6:60,7:70}
d1.pop (5)
5
60
· 6
· 50
1. What is the output of the code?
d1 = {1:10, 2:20, 3:30, 4:40, 5:50, 6:60, 7:70}
del d1 [3]
print (d1)
· {3: 30}
· {1:10, 2: 20, 4: 40, 5: 50, 6: 60, 7: 70}
{4: 40}
· {1:10, 2: 20, 3: 30, 5: 50, 6: 60, 7: 70}
1. What is a Python library created for mathematical operations?
· Spacy
· Pandas
· Numpy
· Sklearn
1. What is the name of the function used to create an array?
· np.tuple()
· np.array()
· np.list()
· np.arange()
1. What is the use of zeros() function in Numpy array in python?
· To make an empty Matrix
· To make a Matrix with all diagonal element 0
· To make a Matrix with first row 0
· To make a Matrix with all element 0
1. What is an output of np.arange(2,8,1)?
· 2,3,4,5,6,7
· 2,3,4,5,6
· 2,3,4,5,6,7,8
· 2,4,6,8
1. Which of the following find the maximum number in the Numpy array?
max_array()
array_max()
max(array)
array(max)
1. What is the output of the following operations?
names = np.array(["Reem" , "Salah" , "Haya" , "Maryam" , "Fatema"])
print(names[[2,3,4]])
· [ 'Haya' 'Maryam' 'Fatema' ]
· [ 'Reem' 'Salah' 'Haya' ]
· [ 'Maryam' 'Haya' 'Fatema' ]
· [ 'Reem' 'Salah' 'Fatema' ]
1. What is a correct method to join two or more arrays?
· np.join()
· np.concatenate()
· np.combine()
· np.merge()
1. What is the output of the code?
import numpy as np
a = np.array([[0, 1, 2], [3, 4, 5]])
b = a.sum(axis=0)
print (b)
· [1 5 6]
· [0 5 7]
· [3 5 7]
· [3 4 6]
1. What is the correct method to sort the elements of an array?
np.split()
np.add()
np.sort()
np.reverse()·
1. Each location of an element in an array is called _____
· Length
· Element
· Index
· Size
1. What is the most popular open-source Python library used for doing data analysis?
· Pandas
· Matplotlib
Numpy
What are the two basic and universally-popular data structures of Pandas?
· Series and DataFrame
· Series and Pandas
· Numpy and DataFrame
1. In a data frame axis -0 is for _____
· Rows
· None of these
· Rows and Columns both
· Columns
1. Which method applies the function on each individual data element of the dataframe?
· plot()
· apply()
· hist()
· bar()
1. Selecting a single column from a DataFrame object returns:
· A Series
· A list
· Another DataFrame
· A numpy array
1. What happens when you multiply a DataFrame like df * 2?:
· Returns a DataFrame with the rows doubled
· Raises a "bad operand type" error
· · Returns a DataFrame with element-wise application of df * 2
· Returns a DataFrame with the columns doubled
1. Which of these will not select the column named foo from DataFrame df?:
1. Which function from the options given below can read the dataset from a large text file?
· read_pickle
· read_csv
· read_hdf
· read_json
1. In Dataframe, loc function is used to choose ____
· all of them
· cells
· rows
· columns
In Dataframe, a function used to find NaN values is ____
· isnull()
· isempty()
· isfull()
· isno()
1. Python library used for data visualization is called
· tensorflow
· matplotlib
· keras
· sklearn
1. What will this command plt.title('String Title Here') do?
· Set a name of x axis
· Set a color of the graphic
· Set a header of the graphic
· Set a legend of the graphic
1. How many plots will be created by this command?
fig, axes = plt.subplots(nrows=1, ncols=2)
3
1
4
2
1. How many lines will be created by the following command?
fig, ax = plt.subplots()
ax.plot(x, x**2, 'b.-') # blue line with dots
ax.plot(x, x**3, 'y--') # green dashed line
3
5
4
2
1. How many plots will be created by this command?
fig, ax = plt.subplots(2, 3)
fig.tight_layout()
3
8
2
6
