<jupyter_start><jupyter_text>1-5 Intro Python Practice   conditionals, type, and mathematics extended   &nbsp; Student will be able to  - code more than two choices using **`elif`** - gather numeric input using type casting  - perform subtraction, multiplication and division operations in code  &nbsp;    &nbsp;   Tasks  Rainbow colorsask for input of a favorite rainbow color first letter: ROYGBIV  Using `if`, `elif`, and `else`:  - print the color matching the letter      - R = Red      - O = Orange      - Y = Yellow      - G = Green    - B = Blue    - I = Indigo    - V = Violet    - else print "no match"<jupyter_code># [ ] complete rainbow colors
userColor = input("Enter the first letter of your favorite color: ")
if userColor.upper() == 'R':
    print("Red")
elif userColor.upper() == 'O':
    print("Orange")
elif userColor.upper() == 'Y':
    print("Yellow")
elif userColor.upper() == 'G':
    print("Green")
elif userColor.upper() == 'B':
    print("Blue")
elif userColor.upper() == 'I':
    print("Indigo")
elif userColor.upper() == 'V':
    print("Violet")
else:
    print('No match')

# [ ] make the code above into a function rainbow_color() that has a string parameter, 
# get input and call the function and return the matching color as a string or "no match" message.
# Call the function and print the return string.
def rainbow_color(string):
    if string.upper() == 'R':
        return "Red"
    elif string.upper() == 'O':
        return "Orange"
    elif string.upper() == 'Y':
        return "Yellow"
    elif string.upper() == 'G':
        return "Green"
    elif string.upper() == 'B':
        return "Blue"
    elif string.upper() == 'I':
        return "Indigo"
    elif string.upper() == 'V':
        return "Violet"
    else:
        print('No match')
        
userColor = input("Enter the first letter of your favorite color: ")

print(rainbow_color(userColor))<jupyter_output>Enter the first letter of your favorite color: y
Yellow<jupyter_text>&nbsp;  **Create function age_20() that adds or subtracts 20 from your age for a return value based on current age** (use `if`) - call the funtion with user input and then use the return value in a sentence  example `age_20(25)` returns **5**: > "5 years old, 20 years difference from now"<jupyter_code># [ ] complete age_20()
def age_20(age):
    if age < 20:
        return age + 20
    elif age >= 20:
        return age - 20

userAge = int(input("Enter your age: "))
print(age_20(userAge), "years old, 20 years difference from now")<jupyter_output>Enter your age: 31
11 years old, 20 years difference from now<jupyter_text>**create a function rainbow_or_age that takes a string argument**- if argument is a digit return the value of calling age_20() with the str value cast as **`int`** - if argument is an alphabetical character return the value of calling rainbow_color() with the str- if neither return FALSE<jupyter_code># [ ]  create rainbow_or_age()
def rainbow_or_age(string):
    if string.isdigit():
        return age_20(int(string))
    elif string.isalpha():
        return rainbow_color(string)
    else:
        return False
    
userInput = input('Enter your age or letter of favorite rainbow color: ')

print(rainbow_or_age(userInput))

# [ ]  add 2 numbers from input using a cast to integer and display the answer 
firstNumber = int(input("Enter a whole number: "))
secondNumber = int(input("enter a second whole number: "))

print(str(firstNumber), "+", str(secondNumber), "=", firstNumber + secondNumber)

# [ ] Multiply 2 numbers from input using cast and save the answer as part of a string "the answer is..."
# display the string using print
firstNumber = int(input("Enter a whole number: "))
secondNumber = int(input("enter a second whole number: "))

answer = "The answer is ... " + str(firstNumber * secondNumber)

print(answer)
# [ ] get input of 2 numbers and display the average: (num1 + num2) divided by 2
firstNumber = int(input("Enter a whole number: "))
secondNumber = int(input("enter a second whole number: "))

print((firstNumber + secondNumber) / 2)

# [ ] get input of 2 numbers and subtract the largest from the smallest (use an if statement to see which is larger)
# show the answer
firstNumber = int(input("Enter a whole number: "))
secondNumber = int(input("enter a second whole number: "))

if firstNumber > secondNumber:
    print(firstNumber - secondNumber)
else:
    print(secondNumber - firstNumber)

# [ ] Divide a larger number by a smaller number and print the integer part of the result
# don't divide by zero! if a zero is input make the result zero
# [ ] cast the answer to an integer to cut off the decimals and print the result
firstNumber = int(input("Enter a whole number: "))
secondNumber = int(input("enter a second whole number: "))

if firstNumber == 0:
    print(0)
elif secondNumber == 0:
    print(0)
elif firstNumber > secondNumber:
    print(int(firstNumber / secondNumber))
elif secondNumber < firstNumber:
    print(int(secondNumber / firstNumber))<jupyter_output>Enter a whole number: 2
enter a second whole number: 1
2
{'fraction_non_alphanumeric': 0.11019120835797358, 'fraction_numerical': 0.010841711019120836, 'mean_word_length': 3.764319248826291, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '27645', 'license': 'MIT', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1462, 'n_words': 605, 'path': 'Python Absolute Beginner/Module_3_Practice_2_IntroPy.ipynb', 'repo_name': 'jmock78/pythonteachingcode', 'size': '5073'}