0% found this document useful (0 votes)
15 views3 pages

Practice Python Course-Cgf

The document contains a Python practice quiz with multiple-choice questions covering various programming concepts, including code output, variable legality, and list manipulation. Each question is assigned a point value, and the quiz tests knowledge on Python syntax and behavior. The questions range from basic operations to more complex data structures like lists and dictionaries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Practice Python Course-Cgf

The document contains a Python practice quiz with multiple-choice questions covering various programming concepts, including code output, variable legality, and list manipulation. Each question is assigned a point value, and the quiz tests knowledge on Python syntax and behavior. The questions range from basic operations to more complex data structures like lists and dictionaries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like