• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Examen

Python Exam Questions and Answers

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

Python Exam Questions and Answers Which of the following is correct about Python? a. Python is a high-level, interpreted, interactive and object-oriented scripting language. b. Python is designed to be highly readable. c. It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages. d. All of the above d. All of the above. Is Python case sensitive when dealing with identifiers? a. yes b. no c. it depends on context d. it depends on data type a. yes Which of the following is an invalid variable? a. my_string b. __a c. 1st_string d. foo_24 c. 1st_string All keywords in Python are in a. lower case b. UPPER CASE c. Capitalized d. None of the above d. None of the above ______________(str) is the function to run in the shell to find out details about how to use str() and the type of data it accepts and returns. help Which of the following is an invalid statement? a. abc = 1,000,000 b. a b c = c. a,b,c = 1, 2, 3 d. a_b_c = 4,000,000 b. a b c = Which one of the following have the highest precedence in the expression? a. Exponential b. Addition c. Multiplication d. Parentheses d. Parentheses Following set of commands are executed in shell, what will be the output? str = "hello" str[:2] he; because you are printing only the first two bytes of string. The following is displayed after a print() call: tom dick harry Select the function call that results in this output a. print("ttom tdick tharry") b. print("ttom tdick tharry") c. print(" tom dick harry") d. print("ttomntdickntharry") d. print("ttomntdickntharry") What is the output of the following code: x = ['ab', 'cd'] for i in x: - i. upper() print(x) ['ab', 'cd'] What is the output of the following? True = False while True: - print(True) - break a. True b. False c. None d. none of the above d. none of the above What is the output of the following? x = 'abcdef' i = "a" while i in x: - print ('i', end = " ") and why? i i i i i i i i ..... because, you are running a while loop, therefore until i is not found in x it will continue to run. "a" will always be found in the string of characters 'abcdef', therefore: i i i i i i i, will never end. What is the output of the following? x = 'abcd' for i in range(len(x)): - print(()) a. a b c d b. 0 1 2 3 c. error d. 1 2 3 4 a. a b c d What is the output of the following? x = 2 for i in range(x): - x += 1 - print(x) a. 0 1 2 3 4 .... b. 0 1 c. 3 4 d. 0 1 2 3 c. 3 4 What is the output of the following? string = "my name is x" for i in string: - print(i, end = ", ") a. m, y, , n, a, m, e, , i, s, , x, b. m, y, , n, a, m, e, , i, s, , x c. my, name, is, x, d. error a. m, y, , n, a, m, e, , i, s, , x, What is the output when the following code is executed? print(r"nhello") a. a new line and hello b. the letter r and then hello c. error d. nhello c. error The output of the following? print("Hello {name1} and {name2}".format(name1 = 'foo', name2 = 'bin')) gives you: Hello foo and bin Why? Because the arguments are accessed by their names. What is the output of the following? print('abcdef12'.replace('cd', '12')) a. abcdef12 b. ab12ef12 c. ab12efcd d. none of the above b. ab12ef12 Which of the following operator in python evaluates to true if it does not finds a variable in the specified sequence and false otherwise? a. ** b. // c. is d. not in d. not in You have the following code: d = {"john":40, "peter":45} print(d["john"]) What type of data structure is 'd'? Also, what do you receive from the second line? (separate your answers by a single space) d is a dictionary you receive the number 40 because "john":40 Which of the following statement terminates the loop statement and transfers execution to the statement immediately following the loop? a. continue b. break c. exit d. pass b. break Which of the following functions reverses objects of lists in place? a. ([func]) b. se() c. (obj=list[-1]) d. e(obj) b. se()

Vista previa del contenido

Python Exam Questions and Answers

Which of the following is correct about Python?

a. Python is a high-level, interpreted, interactive and object-oriented scripting language.
b. Python is designed to be highly readable.
c. It uses English keywords frequently where as other languages use punctuation, and it
has fewer syntactical constructions than other languages.
d. All of the above - answer d. All of the above.

Is Python case sensitive when dealing with identifiers?

a. yes
b. no
c. it depends on context
d. it depends on data type - answer a. yes

Which of the following is an invalid variable?

a. my_string
b. __a
c. 1st_string
d. foo_24 - answer c. 1st_string

All keywords in Python are in

a. lower case
b. UPPER CASE
c. Capitalized
d. None of the above - answer d. None of the above

______________(str) is the function to run in the shell to find out details about how to
use str() and the type of data it accepts and returns. - answer help

Which of the following is an invalid statement?

a. abc = 1,000,000
b. a b c = 1000 2000 3000
c. a,b,c = 1, 2, 3
d. a_b_c = 4,000,000 - answer b. a b c = 1000 2000 3000

Which one of the following have the highest precedence in the expression?

, a. Exponential
b. Addition
c. Multiplication
d. Parentheses - answer d. Parentheses

Following set of commands are executed in shell, what will be the output?
>>> str = "hello"
>>> str[:2]
>>> - answer he; because you are printing only the first two bytes of string.

The following is displayed after a print() call:
tom
dick
harry
Select the function call that results in this output

a. print("\ttom
\tdick
\tharry")
b. print("\ttom \tdick \tharry")
c. print(" tom dick harry")
d. print("\ttom\n\tdick\n\tharry") - answer d. print("\ttom\n\tdick\n\tharry")

What is the output of the following code:
x = ['ab', 'cd']
for i in x:
-> i. upper()
print(x) - answer ['ab', 'cd']

What is the output of the following?
True = False
while True:
-> print(True)
-> break

a. True
b. False
c. None
d. none of the above - answer d. none of the above

What is the output of the following?
x = 'abcdef'
i = "a"
while i in x:
-> print ('i', end = " ")
and why? - answer i i i i i i i i .....

Información del documento

Subido en
10 de mayo de 2025
Número de páginas
5
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$16.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Pogba119
4.0
(15)
Vendido
67
Seguidores
2
Artículos
5654
Última venta
1 semana hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes