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