Last active
February 4, 2016 03:49
-
-
Save d30jeff/3d2625646aacd7764a00 to your computer and use it in GitHub Desktop.
With comment
This file contains hidden or 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
| task_num = 1 | |
| # total task number dia bagi 1 | |
| def questions(): | |
| # Function bernama 'questions' | |
| print ("Please select symbol") | |
| # Print keluar text di atas. | |
| symbol = input() | |
| # Prompt input dan lepas tu input value dari user dalam variable 'symbol' | |
| print ("'{}' has been selected as the symbol.".format(symbol)) | |
| # Print user bagitau symbol apa yang sudah dia pilih | |
| print ("Please specify the height") | |
| # Prompt minta height | |
| height = input() | |
| # Store value yang kena key in dalam 'height' variable | |
| for x in range(0, int(height)): | |
| # Kita loop dari 0 sampai 'height' yang user letak. | |
| print( str(symbol) * int(7)) | |
| # Dalam python you boleh darab string. Sekarang ni dia darab string tu 7 kali. | |
| # Language lain buat for loop pun boleh | |
| print("Do you wish to continue? Y/N") | |
| # Tanya user kalau masih mau continue | |
| return input() | |
| # Return Y/N value | |
| while True: | |
| # Infinite loop | |
| x = questions() | |
| # Ingat function questions di atas yang ada "return input"? | |
| # Letak return input tu dalam variable 'x' | |
| if x.upper() == "N": | |
| # Kalau huruf n yang sudah kena convert ke upper case sama dengan "N" | |
| print("Task completed: {}".format(task_num)) | |
| # 'task_num' datang dari line paling atas tu | |
| break | |
| # Kasi break inifinite loop ni | |
| task_num += 1 | |
| # Kalau user input tu bukan samna dengan "N", tambah task_num dengan 1 | |
| # Loop/ Ulang semula code dalam 'While True:' statement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment