Test
Python Quiz
Este test tiene tiempo límite, así que se abre en el reproductor de siempre.
Preguntas del test (38)
1Examine the code and determine the value of the variable b when the code completes.
- A6
- B2
- CNone
2Examine the code and determine the output.
- A{}
- Bfoo
- C{'obj_name': 'foo'}
- D{'obj_name' = 'foo'}
3What output will be produced from this snippet of code?
- AIndexError
- B[]
- C['a', 'b', 'c', 'd', 'e']
4What output will be produced?
- Ain except block
- Bin except block
after try-except
5What is the value of variable d when the code completes?
- A[1, 'Dublin', 2, 'London', 3, 'Moscow']
- B{1: 'Dublin', 2: 'London', 3: 'Moscow'}
- CAn exception is raised
6Is the code performing legal operations?
- AYes
- BNo
7Do a and b return the same object type?
- ANo
- BYes
8Determine the value of the variable b when the code completes?
- A[10,20,30]
- B20
- C[10, 20, 50]
9What is the output from this code?
- AFalse
- BTrue
10What is the output of the code?
- A15
- B25
- CTrue
11What is the output of the code?
- A'age under 30'
- B'age equals 25'
- CNone of the above
12Determine the output of the code?
- A{house:1215}, 'apt
- BAn exception is raised
- C 'apt', {house:1215}
13What is the output?
- A0 2
- Bjohn sarah
- CAn exception is raised
14What is the value of the variable name when the code completes?
- AKim
- BSam
15Is new_list a shallow or deep copy of old_list?
- Ashallow
- Bdeep
16Determine what the output will be?
- A['j','o','h','n']
- B'John'
- C'mylist'
17What is the output of the code?
- Alist
- Bset
- Cdictionary
18Determine the value of a after the method is called twice.
- A[10, 10]
- B[]
- C[10]
19Determine the output of the code?
- A50
- B40
- C70
20What is the output of the code?
- A'Sar'
- B'Sarah'
- C'Sa'
21What is the output of the code?
- ANone
- B4
22Review the code. Does the variable a have a type? If so, what is the type of a?
- AVariable a does not have a type
- BVariable a is of type List
- CVariable a is of type String
23Is that code legal?
- AYes
- BNo
24Determine the result?
- A2
- B1
25Is the code legal or illegal?
- Alegal
- Billegal
26What is the result of the code?
- A'today'
- B'TODAY'
- C'str'
27What output does the code produce?
- A ['jack', 'peter', 'sarah']
- B ['sarah']
- C [ 'sarah', 'peter', jack']
28Analyse the code and determine the result
- AInfinite loop
- BThe code prints the following: 2 Joe
- CThe code prints the following: 1 2 Mary
29What is the output?
- A[10]
- Braises an exception
- C[[10]]
30What object types do variables a and b point to?
- Aa and b point to a tuple
- Ba points to an int; b points to a tuple
- Ca and b point to an int
31What is the difference between a tuple and a list?
- AA tuple is immutable and a list is mutable.
- BA list is immutable and a tuple is mutable.
32Is a list a heterogeneous data structure in Python?
- AYes
- BNo
33If a list is mutable in Python, can it hold immutable objects?
- AYes
- BNo
34A tuple is an immutable data structure in Python. Can it hold mutable objects?
- ANo
- BYes
35Which line of code is correct to detect if a variable is a function?
- Ahasattr(obj, '__call__')
- Bisinstance(x, function)
- Ctype(x) == 'function'
36What is PEP 8?
- AIt runs Python bytecode
- BIt is a data structure
- CIt is a code style guideline
37What is the "__init__.py" file for in a Python source directory?
- AIt's a constructor
- BMarks a directory as a Python package
38I want to read from a file on the path 'C:\newfile\textfile.txt'. What is the correct way to open the file?
- Amyfile = open('C:\newfile\textfile.txt', 'r')
- Bmyfile = open(r'C:\newfile\textfile.txt', 'r')
Información
- Descripción
- A beginners quiz to aid learning Python.
- Autor
- Harvey Parkes
- Idioma
- English
- Visitas
- 0
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test