WorksheetsPython lists & file operations
Total questions: 10
Worksheet time: 8mins
How is a list created?
a = 3, 5
a = [3, 5]
a = {3, 5}
a = list
Which python code means; assign 25 to the variable x2?
25 = x2
x2 = 25
x2, 25
25, x2
a = [2, 5, 8, 1]
print("a[2]")
What is the output above?
5
8
a[2]
2
list1 = ["hello", "hey", "hi"]
print(list1)
How many items will be printed?
1
2
3
0
filename="example.txt"
with open(filename, "w") as myfile:
myfile.write("Pershendetje")
What happens here?
a file called 'example' is being read
a file called 'example' is created and some text is saved in it.
The text in the 'example' file is assigned to a variable
a variable called filename is created and it's value is printed on a file
Write the code how to print the number of items of a list called 'mylist'?
(a)
What do you think about the difficulty level of Python?
Very difficult
A little difficult
Average
Not difficult
Easy
Select the one(s) which suits you.
I can write codes in python
I can create a list and let user add items to the list
I can create a text file and print some text to it
I can read some text from a file
Write the python code to create an empty list and let the user add 15 values to it. Later print all items in separate lines.
Which statement is correct for adding the value 5 to a list called x?
x.add(5)
x.append(5)
x.pop(5)
x.insert(5)
