Last active
December 13, 2019 12:33
-
-
Save Bundi-py/9b4a618820972b82faa06abf32c2ccd1 to your computer and use it in GitHub Desktop.
Zadatak broj 1: Pogađanje zamišljenog broja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ovo je igra pogađanja brojeva. | |
import random | |
tajniBroj = random.randint(1, 20) | |
print('Zamislio sam jedan broj između 1 i 20.') | |
print('Šta misliš koji je?') | |
print() | |
# Suparnik ima na raspolaganju 6 pokušaja. | |
for brojPokushaja in range(1, 7): | |
pokushaj = int(input('Unesi neki broj: ')) | |
if pokushaj < tajniBroj: | |
print('Tvoj broj je suviše mali.') | |
print() | |
elif pokushaj > tajniBroj: | |
print('Tvoj broj je suviše velik.') | |
print() | |
else: | |
break # Ovo je uslov za pogođen broj! | |
if pokushaj == tajniBroj: | |
print('Bravo majstore! Pogodio si moj broj u ' + str(brojPokushaja) + ' pokušaja!') | |
else: | |
print('Neće biti. Broj koji sam zamislio je ' + str(tajniBroj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment