NEW
Font size
WorksheetsPython Final Assessment
Total questions: 10
Worksheet time: 5mins
Which of the following command is used to open a file “c:\temp.txt” in read-mode only?
infile = open(“c:\temp.txt”, “r”)
infile = open(“c:\\temp.txt”, “r”)
infile = open(file = “c:\temp.txt”, “r+”)
infile = open(file = “c:\\temp.txt”, “r+”)
Which of the following commands can be used to read “n” number of characters from a file using the file object <file>?
file.read(n)
n = file.read()
file.readline(n)
file.readlines()
what will be the output of following code:
list = [ 'Tech', 404, 3.03, 'Beamers', 33.3 ]
print (list[1:3])
[ 'Tech', 404, 3.03, 'Beamers', 33.3 ]
['Tech', 'Beamers']
[404, 3.03]
Error
Which of the following functions print the output to the console?
output()
print()
echo
print.show()
What gets printed as the output of the below code?
x = True
y = False
z = False
if not x or y:
print 1
elif not x or not y and z:
print 2
elif not x or y or not y and x:
print 3
else:
print 4
4
3
2
1
What is the correct file extension for Python files?
pt
txt
python
py
What is the correct syntax to output the type of a variable or object in Python?
print(type(x))
print(typeof(x))
print(typein(x))
print(value(x))
What is the correct way to create a function in Python?
function myFunction()
define Func()
function()
def myFunction()
Which operator is used to multiply numbers?
*
x
mul
#
Which of these collections defines a LIST?
["Apple", "Banana", "cherry"]
{"Apple", "Banana", "cherry"}
"Apple", "Banana", "cherry"
["Apple": "Banana", "cherry":"Apple"]
