tp8_2de.py

Created by jean-luc-poncin

Created on December 13, 2021

227 Bytes

Ex 8.1

Exécuter une suite d’instructions faisant intervenir des affectations et deux variables a et b

Ex 8.2

  • Exécuter p ← 10000 puis 4 fois p ← p * 1,05 – 400
  • Transformer la séquence précédente en boucle Pour
  • Réécriture de la boucle Pour avec le paramètre n pour obtenir n répétitions


# Ex 8.2, questions 2, 3, 4

def pop1():
  p=10000
  for i in range(1,5):
    p=p*1.05-400
  return(p)

# Ex 8.2, questions 5, 6, 7

def pop2(n):
  p=10000
  for i in range(1,n+1):
    p=p*1.05-400
  return(p)
  

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.