• 6 heures
  • Facile

Ce cours est visible gratuitement en ligne.

course.header.alt.is_certifying

J'ai tout compris !

Mis à jour le 02/08/2023

Use Specialized Python Libraries

Compétences évaluées

  • Use specialized Python libraries
  • Question 1

    Check the numbers that can be obtained if the following code is run:

    import random
     
    n = random.uniform(10,19)
    print(n)
    
    Attention, plusieurs réponses sont possibles.
    • 6

    • 10.0

    • 14.4

    • 23.0

    • 10.5

    • 19.0

  • Question 2

    What should the ... be replaced with, so that the following program prints one of the names in the list at random?

    import random
    
    basket = ["Apple", "Pear", "Banana", "Pineapple", "Orange"]
    result = ...
    print(result)
    
    Attention, plusieurs réponses sont possibles.
    • basket[random.randint(0, 4)]

    • random.choice(basket)

    • random.random(basket)

    • random.shuffle(basket)

  • Question 3

    Consider the following experiment:

    A normally-balanced die (with six faces) is thrown 10,000 times. Among these 10,000 throws, 1,000 are taken at random.

    We carry out this experiment five times, and we write down m, the average number of times we get the number six out of the 10,000 throws, and n, the average number of times we get the number four in the subsample.

    What would be the values of m and n at the end of this experiment?

    • Randomness makes the results too variable to answer this question precisely.

    • m  and   n  will be close to 1/6.

    • m  will be close to 1/6,   n  will be close to (1/6)/10 = 1/60.

    • m  will be close to 1/6 and it is not possible to know for   n  because of the randomness.

Et si vous obteniez un diplôme OpenClassrooms ?
  • Formations jusqu’à 100 % financées
  • Date de début flexible
  • Projets professionnalisants
  • Mentorat individuel
Trouvez la formation et le financement faits pour vous