Mr. Gottsacker
Computer Programming
Note: In the example code, keyboard input from the user will be represented using bold, bright green
.
Write a program that plays the "odds game." Prompt the user to enter a task for which they want to play the game. Then, prompt the user to enter the highest bounds of the odds game. Generate a random number between 1 and that upper bound. Prompt the user to enter the number they are guessing, and tell them whether they guessed the number.
Sample runs:
What are the odds...
What task are you putting on the line? eat a tablespoon of cinnamon
What are the odds you will eat a tablespoon of cinnamon? 1 in 20
Enter your number between 1 and 20: 6
The computer generated 6 as well. You must eat a tablespoon of cinnamon!
What are the odds...
What task are you putting on the line? drink a gallon of milk
What are the odds you will drink a gallon of milk? 1 in 50
Enter your number between 1 and 50: 26
The computer generated 15. You do not have to drink a gallon of milk.
Write a program that gives the user up to three addition quizzes. Each quiz should generate two integers between 10 and 20, and prompt the user to answer the sum of them. After each of the first two quizzes, ask the user whether they want to continue. After the final quiz (or after they choose to stop answering questions), print the user's score as a percentage with two decimal places.
Sample runs:
What is 13 + 15? 28
That is correct. Would you like another quiz? (y/n): y
What is 11 + 20? 30
That is incorrect. Would you like another quiz? (y/n): n
Your score is 50.00%
What is 14 + 11? 25
That is correct. Would you like another quiz? (y/n): y
What is 11 + 11? 22
That is correct. Would you like another quiz? (y/n): y
What is 13 + 14? 30
That is incorrect.
Your score is 66.67%
Write a program that prompts the user to enter a 6-character plaintext password that contains at least one of the following:
Shift + [number]
)Sample runs:
This program verifies that your 6-character plaintext password contains at least one of each of the following:
- uppercase letter
- lowercase letter
- number
- special symbol (such as ! or @ or #)
Enter your password: sAfe!1
That password meets our strength requirements.
This program verifies that your 6-character plaintext password contains at least one of each of the following:
- uppercase letter
- lowercase letter
- number
- special symbol (such as ! or @ or #)
Enter your password: secur3
That password does not meet our strength requirements.
Specifically, your password does not include the following:
- uppercase letter
- special symbol
This program verifies that your 6-character plaintext password contains at least one of each of the following:
- uppercase letter
- lowercase letter
- number
- special symbol (such as ! or @ or #)
Enter your password: sUp3rS3cur3!
While potentially very strong, that password is too long to be processed.
Write a program that prompts the user to enter a 6-character plaintext password. Transform the password to make it stronger. Specifically:
character | leet |
---|---|
a or A | @ |
e or E | 3 |
s or S | $ |
Sample runs:
Enter a 6-character plaintext password: secure
Your strengthened password is: $3cuR3
Enter a 6-character plaintext password: longPassword
Your password is too long to be processed.