Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need help with the purple boxes thank you Activity 5: Write a program called favorite.py that asks the user to enter a color name. If
need help with the purple boxes thank you
Activity 5: Write a program called favorite.py that asks the user to enter a color name. If the color entcred happens to be your favorite color, print a message "We have the same tavorite color!". Otherwise, do not print any response. (Be very careful with punctuation in this program. The if clause must end with a colon, or python will complain.) copy and paste your favorite.py here # Copy and paste your favorite.py here Activity 7: In most of the Python peograms, you will want to interact with the user by the user inputs. For example, pcople int input"How many people are there?") This line of code would work as long as the user enters an integer. However, some input, such as 1, doesn't make sense for the number of people. You program should validate the user input before execute the rest of the code. Test the following program with different inputs mport sys # import sys module so that we can use gassO to terminate the execution Notice that to check wbether your program works correctly, you will now have to run it at least twice, entering colors that test both outcomes. people intlinputf"How many people are there?") Now add one statement to your program that will cause it to print "Goodbye!" just before it ends, regardless of the color entered. Obviously, you also want to test your program to make sure it works printInvalid input. The number of people must be a non-negative integer.") ssexin #terminate the execution # copy and paste your whole program here rin"You entered a non-negative integer:", people) Now, plcase write a program to ask the user to input a test score, which must be bctween 0 and 100. Add input validation to your program #copy and paste your code bare Activity 6: Let's return to the program signpy, Suppose we want to print one message when the condition number> 0) is true, and a different message whea the condition is false. We can do that by adding an else clause as shown below. Plcase modify your copy of sign.py in this way and do some experiments to convince yourself that it works. (Again, you must be careful to include the colon after else.) number -iofnutEnter a number: ") print'That number is positive.") else printi"Definitely NOT positive.") Now return to favorite.py and modify your program so that it prints one message if the user enters your favorite color, and a different message ifnot. In addition, your program should print a final message for every user, regardless of what they enteredStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started