Icon Crear Crear

Pure Python code

Test

Test your knowledge of pure Python code

Descarga la versión para jugar en papel

1 veces realizada

Creada por

España

Top 10 resultados

  1. 1
    00:50
    tiempo
    20
    puntuacion
¿Quieres aparecer en el Top 10 de este juego? para identificarte.
Crea tu propio juego gratis desde nuestro creador de juegos
Compite contra tus amigos para ver quien consigue la mejor puntuación en esta actividad

Top juegos

  1. tiempo
    puntuacion
  1. tiempo
    puntuacion
tiempo
puntuacion
tiempo
puntuacion
 
game-icon

Pure Python codeVersión en línea

Test your knowledge of pure Python code

por Álvaro Manuel Navarro Cruz
1

Which line is not correct? Pay attention to the indentation.

2

Is this correct if we want to generate a random number between 1 and 100?

3

Is it necessary to specify the last "elif" condition?

4

Which of the following statements about the filterEvenNumbers() function are correct?

Choose one or more answers

5

What is the purpose of the while loop in the timesTable program?

Feedback

If we leave line 5 in place, the if condition will be empty.

The function random.randint(a, b) generates a random integer including both endpoints a and b. So, random.randint(1, 98) will only generate numbers from 1 up to 98, excluding 99 and 100.

Using else here simplifies the code because all other possibilities have been eliminated by previous checks (if and elif). Since the only remaining case is that the number is equal, else handles it cleanly and reduces redundancy. This approach is common and accepted in programming to keep the code concise.

The while loop in the timesTable program is designed to repeatedly prompt the user to enter numbers and print the corresponding multiplication tables. The loop continues executing as long as the user does not enter the sentinel value -1. When the user inputs -1, the loop terminates, effectively stopping the repetition of multiplication tables. This allows the program to keep running and displaying new tables for different numbers until the user decides to stop by typing -1. Therefore, the purpose of the while loop is to keep printing multiplication tables until the user types -1.

educaplay suscripción