For this lab, and every lab: comment your code. If you use/adapt code from the internet, you must add a comment with the source of the code.
Reading: Chapter 3 https://automatetheboringstuff.com/2e/chapter3/
Activity – Python Tutor: Try at least one program in Python Tutor http://www.pythontutor.com/
Question 1: Greetings Function! (4 points)
Start with the greeting program, the first program with functions we used in Python Tutor. This time, the computer is very happy to meet you. Modify the function to return the user’s name in uppercase, with !!!! after it. So, if the user’s name is Miriam, the greeting function will return ‘HELLO MIRIAM!!!!’
Question 2: Quiz question function (6 points)
Write a function that takes two arguments – a quiz question and the correct answer.
In your function, you will print the question, and ask the user for the answer. If the user gets the answer correct, print a success message. Else, print a message with the correct answer. Your function does not need to return anything.
Call your function with two example quiz questions. Here’s some suggestions,
- Q: What year did Apollo 11 land on the moon? A: 1969
- Q: Who painted the Mona Lisa? A: Leonardo da Vinci
Question 3: Windows 10 Upgrade (10 points)
When installing Windows 10, a user can either wipe everything from their computer and do a clean install. Or if their computer meets system requirements, the user can upgrade to Windows 10 without erasing their current operating system.
To do the upgrade, according to Microsoft, a computer needs to have at least 1GB of memory, and at least 1GHz processor, and either Windows 7 or Windows 8 currently installed. All three requirements must be met.
Write a program that asks the user for
- The current memory in their computer, in GB. (For example, a user with 8GB of memory would enter 8)
- The current processor speed, in GHz. (For example, a user with a 2.6GHz processor should enter 2.6)
- The name of their current operating system. (For example, a user could enter Windows 8 or Windows 7 or Windows XP)
Write a can_upgrade function that takes three arguments, the amount of memory, the processor speed, and current operating system.
In can_upgrade, use conditions to figure out if the user’s computer can be upgraded to Windows 10 or not. Your function should return one of the Boolean values True (if the computer can be upgraded) or False (if it can’t be upgraded).
Call your can_upgrade function from main(), and use the return value to print a message to the user telling them if they can, or can’t, upgrade.
Extra Credit Question: (+5 points)
Start with the College ID card program from https://gist.github.com/claraj/b993219477d015d58341c4f3c1950a22. This has no functions but it would benefit from being re-organized into functions. Refactor this program. Suggestions – functions for validation, functions to help print the college ID card, for example printing a line of —-, printing centered text, printing text in color.