Created
June 21, 2020 23:55
-
-
Save tyaslab/7cfcaa7f0ff6d87ca1cdb881c998541e to your computer and use it in GitHub Desktop.
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
import random | |
def main(): | |
# tentukan angka misteri | |
misteri = random.randint(1, 100) | |
tebakan = 0 | |
counter = 0 | |
while misteri != tebakan: | |
counter += 1 | |
# masukkan angka tebakan | |
tebakan = input('Masukkan angka tebakan: ') | |
tebakan = int(tebakan) | |
# cek angka tebakan dengan angka misteri | |
if tebakan == misteri: | |
print(f'Anda benar! Anda telah mencoba sebanyak {counter} kali') | |
elif tebakan > misteri: | |
print('Tebakan Anda kebesaran!') | |
else: | |
print('Tebakan kekecilan!') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment