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 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.
5What output will be produced?
- Ain except block
- Bin except block
after try-except
6Is a list a heterogeneous data structure in Python?
- AYes
- BNo
7If a list is mutable in Python, can it hold immutable objects?
- AYes
- BNo
8A tuple is an immutable data structure in Python. Can it hold mutable objects?
- ANo
- BYes
9What 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
10Is the code performing legal operations?
- AYes
- BNo
11Do a and b return the same object type?
- ANo
- BYes
12Determine the value of the variable b when the code completes?
- A[10,20,30]
- B20
- C[10, 20, 50]
13What is the output from this code?
- AFalse
- BTrue
14What is the output of the code?
- A15
- B25
- CTrue
15What is the output of the code?
- A'age under 30'
- B'age equals 25'
- CNone of the above
16Determine the output of the code?
- A{house:1215}, 'apt
- BAn exception is raised
- C 'apt', {house:1215}
17What is the output?
- A0 2
- Bjohn sarah
- CAn exception is raised
18Which line of code is correct to detect if a variable is a function?
- Ahasattr(obj, '__call__')
- Bisinstance(x, function)
- Ctype(x) == 'function'
19What is PEP 8?
- AIt runs Python bytecode
- BIt is a data structure
- CIt is a code style guideline
20What is the value of the variable name when the code completes?
- AKim
- BSam
21What is the "__init__.py" file for in a Python source directory?
- AIt's a constructor
- BMarks a directory as a Python package
22Is new_list a shallow or deep copy of old_list?
- Ashallow
- Bdeep
23Determine what the output will be?
- A['j','o','h','n']
- B'John'
- C'mylist'
24What is the output of the code?
- Alist
- Bset
- Cdictionary
25Determine the value of a after the method is called twice.
- A[10, 10]
- B[]
- C[10]
26Determine the output of the code?
- A50
- B40
- C70
27What is the output of the code?
- A'Sar'
- B'Sarah'
- C'Sa'
28What is the output of the code?
- ANone
- B4
29I 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')
30Review 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
31Is that code legal?
- AYes
- BNo
32Determine the result?
- A2
- B1
33Is the code legal or illegal?
- Alegal
- Billegal
34What is the result of the code?
- A'today'
- B'TODAY'
- C'str'
35What output does the code produce?
- A ['jack', 'peter', 'sarah']
- B ['sarah']
- C [ 'sarah', 'peter', jack']
36Analyse the code and determine the result
- AInfinite loop
- BThe code prints the following: 2 Joe
- CThe code prints the following: 1 2 Mary
37What is the output?
- A[10]
- Braises an exception
- C[[10]]
38What 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
Información
- Descripción
- A beginners quiz to aid learning Python.
- Autor
- karljmurphy
- Idioma
- English
- Visitas
- 876
- Etiquetas
- Valoración
- 4,0 de 5 · 11 valoraciones Valora este test