PRACTICE
PYTHON PRACTICE
Names and Surnames: César Alejandro Grande Flores Delivery Date: 28-01-23
Questions (1.5 pts each)
1. What is the result of the following code?
x = 1 / 2 + 3 // 3 + 4 ** 2 print (x)
a. 17.5 b.17 c.8 d.8.5
2. What is the output of the following code snippet?
x = 1 y = 2 z = x x = y y = z print ( x, y )
12
3. What is the result of the following code fragment if a 2 and a 4 are introduced?
respectively?
x = int(input()) y = int(input()) x = x / y y = y / x print(y)
8.0
4. Which of the following variable names are illegal? (Select two)
answers)
and
5. What is the result of the following code?
z = y = x = 1 print(x, y, z, sep='x')
x*y*z
6. Which of the following statements are true? (Select two answers)
The operator ** uses right-side binding.
b. The result of the operator / is always an integer value.
c. Addition precedes multiplication
d. The argument to the right of the % operator cannot be zero.
7. What is the correct code to create a list of names?
a. nameList = John, Harry, Jesse, John, Harry, Harry
b. nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
c. nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
d. nameList = [John, Harry, Jesse, John, Harry, Harry]
8. Which of these code snippets would return the name "Harry" from the following
list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
a. nameList()
PRAC
b. nameList[1]
c. NameList(4)
d. nameList["4"]
9. In what follows, what are the keys?
Anna
a. {}, :, '', []
Anna
name
d. None of the above
10. In the following code:
numbers = tuple("12345")
numbers
The result of the previous program is:
a. ('1', '2', '3', '4', '5')
b. (1, 2, 3, 4, 5)
c. 12345
12345
Questions (2.5 pts each)
11. What is the result of the following code?
aList = [10, 20, 30, 40, 50, 60, 70, 80]
print(aList[2:5])
print(aList[:4])
print(aList[3:])
[20, 30, 40, 50]
[10, 20, 30, 40]
[30, 40, 50, 60, 70, 80]
[30, 40, 50]
[10, 20, 30, 40]
[40, 50, 60, 70, 80]
c. [30, 20, 50, 40]
[10, 20, 30, 40]
[40, 50, 60, 70, 80]
[30, 40, 50]
[10, 20, 30, 40]
[40, 60, 80, 100, 120]
12. Which concept does not belong to Dictionary?
a. keys
PRACTICE
b. index
c. repeat
d. slicing