<jupyter_start><jupyter_text>Flow Control  Python `if ... else` The general syntax for Python's if statement is this:```pythonif condition1:     statement1 for True condition1elif condition2 :     statement2 for True condition2elif condition3 :     statement3 for True condition3else:     statements for each condition False```<jupyter_code>score = int(input("請輸入成績"))
if score >= 60:
    print("成績及格!")
else:
    print("不及格，被當了!")
# Click below for a solution

score = int(input("score: "))
if score >= 90:
    print('Grade is: A')
elif score >= 80:
    print('Grade is: B')
elif score >= 70:
    print('Grade is: C')
elif score >= 60:
    print('Grade is: D')
else:
    print('Grade is: F')<jupyter_output>score: 90
Grade is: A<jupyter_text>Python `for ` loopsPython's `for` loop reuses the `in` keyword, and has the following syntax:```pythonfor variable in iterable:     suite```<jupyter_code>sequences = [0, 1, 2, 3, 4]
for i in sequences:
    print(i)
countries = ['Denmark', 'Finland', 'Norway', 'Sweden', 'Taiwan']
for country in countries:
    print(country)
for i in range(10):
    print(i, end=' ')<jupyter_output>0 1 2 3 4 5 6 7 8 9<jupyter_text>`Nested for loops`<jupyter_code># 99乘法表
for i in range(1, 10):
    for j in range(1, 10):
        if j == 9:
            print('\t', i * j)
        else:
            print('\t', i * j, end=' ')<jupyter_output>1 	 2 	 3 	 4 	 5 	 6 	 7 	 8 	 9
	 2 	 4 	 6 	 8 	 10 	 12 	 14 	 16 	 18
	 3 	 6 	 9 	 12 	 15 	 18 	 21 	 24 	 27
	 4 	 8 	 12 	 16 	 20 	 24 	 28 	 32 	 36
	 5 	 10 	 15 	 20 	 25 	 30 	 35 	 40 	 45
	 6 	 12 	 18 	 24 	 30 	 36 	 42 	 48 	 54
	 7 	 14 	 21 	 28 	 35 	 42 	 49 	 56 	 63
	 8 	 16 	 24 	 32 	 40 	 48 	 56 	 64 	 72
	 9 	 18 	 27 	 36 	 45 	 54 	 63 	 72 	 81<jupyter_text>Python `while` loopsThe `while` statement is used to execute a suite zero or more times, the number of times depending on the state of the while loop's condition.Here's the syntax:```pythonwhile boolean_expression:     Body of while```<jupyter_code>i = 1
while i <= 10:
    print(i, end=' ')
    i += 1<jupyter_output>1 2 3 4 5 6 7 8 9 10<jupyter_text>`break` and `continue`<jupyter_code># break

i = 0
while True:
    i += 1
    if i == 10:
        break
    print(i, end=' ')
    
# continue

i = 0
while i < 10:
    i += 1
    if i == 4:
        continue
    print(i, end=' ')<jupyter_output>1 2 3 5 6 7 8 9 10<jupyter_text>Exercise: Guessing Game<jupyter_code>import random

number = random.randint(1, 100)

print('Guess the number!')

while True:
    print('Please enter your guess:')
    guess = int(input())
    if guess == number:
        print('Good job')
        break
    elif guess < number:
        print('Your guess is too low')
    else:
        print('Your guess is too heigh')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11390585698886094, 'fraction_numerical': 0.08048868127919512, 'mean_word_length': 2.5419847328244276, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '309154', 'license': 'MIT', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1003, 'n_words': 364, 'path': 'Python/01_python_basics/02_flow_control.ipynb', 'repo_name': 'kaka-lin/Notes', 'size': '2783'}