domingo, 21 de septiembre de 2025

Py4E Quiz seccion 2. Variables y declaraciones

 

Bienvenido Python Para Ingenieros de Python for Everybody

  1. In the following code,

    print(98.6)
    
    What is "98.6"?

    A conditional statement

    An iteration / loop statement

    A constant

    A variable

  2. Which of the following is a comment in Python?

    // This is a test

    /* This is a test */

    * This is a test

    # This is a test

  3. What does the following code print out?

    print("123" + "abc")
    

    123abc

    123+abc

    This is a syntax error because you cannot add strings

    hello world

  4. In the following code,

    x = 42
    
    What is "x"?

    A function

    A constant

    A variable

    A Central Processing Unit

  5. Which of the following is a bad Python variable name?

    _spam

    Spam

    SPAM23

    23spam

  6. Which of the following variables is the "most mnemonic"?

    hours

    variable_173

    x1q3z9ocd

    x

  7. Which of the following is not a Python reserved word?

    if

    speed

    else

    for

  8. Which of the following is not a Python reserved word?

    continue

    else

    iterate

    break

  9. Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?

    x = x + 2
    

    Retrieve the current value for x, add two to it and put the sum back into x

    Produce the value "false" because "x" can never equal "x+2"

    This would fail as it is a syntax error

    Create a function called "x" and put the value 2 in the function

  10. Which of the following elements of a mathematical expression in Python is evaluated first?

    Parentheses ( )

    Subtraction -

    Addition +

    Multiplication *

  11. What is the value of the following expression

    42 % 10
    
    Hint - the "%" is the remainder operator

    2

    1042

    420

    10

  12. What will be the value of x after the following statement executes:

    x = 1 + 2 * 3 - 8 / 4
    

    4

    15

    5.0

    3.0

  13. What will be the value of x when the following statement is executed:

    x = int(98.6)
    

    100

    99

    98

    6

  14. What does the Python input() function do?

    Take a screen shot from an area of the screen

    Read the memory of the running program

    Connect to the network and retrieve a web page.

    Pause the program and read data from the user

No hay comentarios.:

Publicar un comentario

Entradas recientes

Python for Everybody (Py4E). Seccion 5.

 Py4E, sección 5. Iteraciones L a sección 5, se enfoca en el concepto de iteraciones y bucles en Python, que son fundamentales para repeti...

Entradas Populares