0% found this document useful (0 votes)
5 views1 page

2023 ds1 Cor - Py

The document contains Python code that includes various functions and loops for mathematical computations. It features turtle graphics to draw shapes, factorial and exponential calculations, and checks for Pythagorean triples. Additionally, it calculates the sum of multiples of 3 and 5 up to 1000 and the sum of the digits of 2 raised to the power of 50.

Uploaded by

ishaq.digennaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

2023 ds1 Cor - Py

The document contains Python code that includes various functions and loops for mathematical computations. It features turtle graphics to draw shapes, factorial and exponential calculations, and checks for Pythagorean triples. Additionally, it calculates the sum of multiples of 3 and 5 up to 1000 and the sum of the digits of 2 raised to the power of 50.

Uploaded by

ishaq.digennaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Fichier : /home/vincent/SynologyDrive/D…/Info/2023_DS1/2023-ds1-cor.

py Page 1 sur 1

# Question 33

import turtle

for i in range(8):
for i in range(3):
turtle.forward(100)
turtle.left(120)
turtle.left(45)

# Question 36

def facto(n):
if n == 0:
return 1
else:
p = 1
for i in range(1, n+1):
p = p*i
return p

def expo(x, k):


s = 0
for n in range(k+1):
s = s + x**n / facto(n)
return s

# Question 37

def expo2(x, e):


s = 0
n = 0
u = x**n / facto(n)
while u > e:
s = s + u
n = n + 1
u = x**n / facto(n)
return s

# Question 38

n = 1000
s = 0
for i in range(n):
if i %3 == 0 or i % 5 == 0:
s = s + i
print(s)

# Question 39

a = 2**50
b = str(a)
s = 0
for chiffre in b:
s += int(chiffre)
print(s)

# Question 40

def pythagoricien(a, b, c):


return a**2 + b**2 == c**2

# Question 41
""" on suppose a<=b<=c comme a+b+c=1000, alors 2<=500, donc a entre 0 et 500, et c=1000-a-b"""

for a in range(501):
for b in range(a, 501):
c = 1000 - a - b
if pythagoricien(a, b, c):
print(a, b, c)
#(200, 375, 425)

You might also like