tp5_2de_corr.py

Created by jean-luc-poncin

Created on November 16, 2021

1.01 KB

  • utilisation de procédure et de boucles Pour
  • utilisation de variables
  • affichages divers avec print


from math import *
from turtle import *

# Ex 5.1

def rp1():
    for i in range(5):
        print(i)
        
def rp2():
    for i in range(1,9):
        print(10*i)

def rp3():
    for i in range(1,7):
        print(5*i)
    
def rp4():
    for i in range(1,6):
        print(40+i)
        
# Ex 5.2
    
def rpt1():
    for i in range(1,5):
        print("Chapitre")

def rpt2():
    for i in range(1,5):
        print("Chapitre ",i)
        
def rpt3():
    for i in range(1,10):
        print("Exercice ",i)
        
def rpt4():
    for i in range(1,4):
        print("i =",i)

def rpt6():
    for i in range(1,11):
        print(" 7 * ",i," = ",7*i)
        
# Ex 5.3

def f(x):
    return(3*x+4)

def tab1():
    for i in range(1,5):
        print(f(i))
        
def tab2():
    for i in range(1,11):
        print("x =",i,"  f(x) =",f(i))
        
def tab3():
    for i in range(1,11):
        print("f(",i,") =",f(i))
        
def tab4():
    for i in range(1,11):
        print("f(",i,") = ",f(i),sep="")

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.