stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Python _Revision_XII (1 to 5) Flashcards | StudBud
Explore
/
Python _Revision_XII (1 to 5)
Python _Revision_XII (1 to 5)
50 terms
·
StudBud Administration
·
79 plays
First 5 chapters discussed in detail.
Flashcards
50 cards
F
Practice quiz
P
Host live
L
Questions
50
Answers
1
How does one import the random module in Python?
random import
python import random
import random
modnar tropmi
2
Keywords in python are________
Upper case
Lower case
None of the above
Always accepts both cases
3
Which statement about CSV files is FALSE
CSV files can be opened in a word processor
CSV files are used to exchange data between programmes
CSV files usually use commas to separate values in each line
CSV files can store multi-media contents
4
Suppose
d = {“john”:40, “peter”:45}
, to delete the entry for “john” what command do we use?
d.delete(“john”)
del d[“john”]
del d(“john”:40)
d.delete(“john”:40)
5
What will the following code snippet print?
2 1 0
3 2 1 0
0 1 2
1 2 3
6
hat will the following code snippet print?
No output
0 1 2
apple banana cherry
[“apple”, “banana”, “cherry”]
7
What is the syntax for a while loop in Python?
while loop condition:
while condition:
while (condition):
while condition():
8
In Python the default argument is an argument that takes a default value.
False
True
9
What will be the output of the following Python code?
[10,23,56,[78]]
[10,34,56,[95]]
[10,34,56,[78]]
[10,23,56,[95]]
10
Which keyword is used to execute a block of code if the condition in the if statement is false?
else
Except
elif
False
11
What is the output of the following code?
x is less than 3
x is greater than 3
x is equal to 3
No output
12
What is the output when we execute list(“hello”)?
[‘olleh’]
[‘hello’]
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘llo’]
13
How many types of tokens in python?
7
4
5
8
14
Strings in python
mutable
changeable
flexible
immutable
15
Why do we need the "random" module in Python?
None of the above
To select an automated character based on characters saved in a variable
To choose random mathematical numbers
To randomly create a password from the internet
16
BASIC, COBOL, LOGO, Python, and Java are all examples of
Applications
Microchips
Programs
Programming Languages
17
What will be the output of the following Python code?
12
1512
15
Error
18
The readlines() method returns ____________
a list of single characters
a list of lines
str
a list of integers
19
When writing to a CSV using
.writerow()
method of
csv.DictWriter.
What must each key in the input dict represent? E.g.
Each key indicates the row index as an integer for where the data should go
Each key indicates the column index as an integer for where value should go
Each key must match to field (index) names used to identify the row data
Each key must match to field(column) names used to identify the column data
20
What will be the output of the following Python code snippet?
Error
None
False
True
21
What will be the output of the following Python code snippet?
40 and 45
“john”, 40, “peter”, 45
{‘john’: 40, ‘peter’: 45}
d = (40:”john”, 45:”peter”)
22
What is the purpose of the range() function in Python?
To generate a sequence of numbers
To execute a block of code repeatedly until a condition is false
To iterate over items in a sequence
To define a function
23
How can a user-defined function be formulated in Python?
By providing arguments
By using the return statement
By using the def keyword
All of the above
24
How can you exit a loop prematurely in Python?
Using the exit function
Using the pass statement
Using the continue statement
Using the break statement
25
Which of the following is the correct syntax to read from a file using load function?
<object> - load.pickle(<filehandle>)
pickle.load(<filehandle>)
<object> - pickle.load(<file>)
All the Above
26
pass
statement in python
advances one step
does nothing
deletes the next line of code
skips to next line of code
27
Which of the following commands will create a list?
list1 = list([1, 2, 3])
list1 = [ ]
all of the mentioned
list1 = list( )
28
The range function in python returns
tuple
sentence
integer
list
29
Data types in Python
Integer, String, Text
Integer, String, Currency
Integer, String, Float
Integer, String, Char
30
Indentation in python is
Optional
Not important at all
None of the above
Extremely important
31
What is the purpose of string slicing in Python?
To split a string into a list
To extract a substring from a string
To convert strings to numbers
To remove characters from a string
32
For loop in Python:
for i =0; i < 10; i++:
for i in range(10):
for(int i = 0; i < 10; i++){ }
for items not in listOfItems:
33
Use of operators in Python
Symbols that designate that some sort of computation should be performed.
Used for developing websites and software, task automation, etc.
To tell the program to stop and wait for the user to key in the data.
Are used to represent real numbers and are written with a decimal point.
34
What will be the output of the following code snippet?x = 10
x is equal to 5
x is greater than 5
No output
x is less than 5
35
Keyword arguments
Can be in any location
Are part of a dictionary
Won't work for integers
Must be in a specific location
36
What will be the output of the following code?
1 2 4
1 2 4 5
1 2 3
1 2
37
You cannot insert multiple rows in csv file using python csv module.
True
False
38
Precedence of operators in python
Exponentiation>Division>Multiplication>Addition,Subtraction
Exponentiation>Addition>Multiplication>Division>boolean operators
Exponentiation>Multiplication>Division>Addition
Multiplication>Addition>Division>exponential
39
Which of the following file modes will not delete the existing data in binary file?
.a
.w
.wb
.ab
40
Which of the following is the use of function in python?
Functions are reusable pieces of programs
All of the mentioned
you can’t also create your own functions
Functions don’t provide better modularity for your application
41
To read two characters from a file object infile, we use ____________
infile.readline()
infile.read()
infile.readlines()
infile.read(2)
42
Functions in Python...
conjunction junction what's your function?
a section of code with a specific task
do math problems
create an internet connection between the python and computer
43
How can you execute multiple statements under a single if block in Python?
Indent the statements to the same level
Separate statements with a semicolon
se the and keyword between statements
) Use the elif keyword
44
What is the primary purpose of the if statement in Python?
To execute a block of code based on a condition
To define a function
To repeat a block of code
To perform mathematical operations
45
How can you skip the current iteration of a loop and continue with the next iteration?
Using the pass statement
Using the continue statement
Using the skip statement
Using the break statement
46
What is the purpose of the elif statement in Python?
To exit from a loop
To define a loop
To execute a block of code if the previous conditions are false
To perform arithmetic operation
47
Which method of pickle module is used to write onto a binary file?
write()
load()
read()
dump()
48
What does the read() method in Python return?
Bytes object
File object
Contents of the file as a string
List of lines in the file
49
Which of the following are valid escape sequences in Python?
all
\\
\n
\t
50
What will be the output of the following Python code?
[1, 1, 2, 2]
(1, 1, 2, 2)
(1, 2, 1, 2)
[1, 2, 1, 2]