Skip to content
Extraits de code Groupes Projets
Valider 8360179b rédigé par fbury's avatar fbury
Parcourir les fichiers

More exercises in Chapter 2

parent b5ff3688
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
goal = input('Enter the word to guess\n')
tried = ""
goods = ""
lives = 5
win = False
while not win:
if tried:
print("Letters you have tried:", tried)
letter = input('Enter a letter\n')
if letter in tried:
print("You have already tried this letter")
else:
tried += letter
if letter in goal:
print(letter, "is indeed in the goal word")
goods += letter
i = 0
win = True
print("The current word is:", end="")
while i < len(goal):
if goal[i] in goods:
print(goal[i], end="")
else:
print('_', end="")
win = False
i += 1
print()
else:
lives -= 1
print("Unfortunately,",letter,"is not in the goal word")
if lives == 0:
print("You lost !")
break
else:
print(lives, "live(s) remaining")
if win:
print("You win ! The secret word was indeed", goal)
import math
euler = 0
factorial = 1
x = 0
while 1./factorial > 1e-9:
factorial = 1
j = 1
while j <= x:
factorial *= j
j += 1
euler += 1./factorial
x += 1
print ('math value : e = ',math.exp(1),' value from serie : e = ',euler)
nombre = int(input("Entrez un nombre entier\n"))
bit = ""
div = nombre
while div > 0:
reste = div % 2
div = div // 2
if reste == 0:
bit += "0"
else:
bit += "1"
bit = bit[::-1]
print ('My value : ',bit)
print ('Correct value : {0:b}'.format(nombre))
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter