At the top of each of your scripts, put the following multi-line comment with your information:
'''
Your name as registered, with optional nickname in parentheses
CIS 41A Fall 2021
Unit E, Problem E
'''
Write a script that can determine where different plants can be planted.
Each plant has a name, a type (Flower, Vegetable, Tree, etc.), and a maximum height.
There are three gardens as follows:
Print ONE line that identifies the one or more gardens that a given plant can be planted in. If a plant does not match the criteria for any of the gardens, then say so.
Test the script six times with the following test data:
Example output:
Please enter the plant name: Lily Please enter the plant type: Flower Please enter the plant height: 3 A Lily can be planted in the Low Garden or the High Garden. and so on...
Write a script that plays a simple guessing game.
The script will generate a secret number from 1 to 100, inclusive, and the user will have to guess the number.
After each guess, the script will tell the user if they are high, low, or correct.
If they are correct, the script will congratulate the user, tell them how many guesses they took, and then end the script.
Hint: most of the game code will be in a loop that repeats until the correct number is guessed.
To generate the secret number, you will need to use the
randint function
from Python's Random module, as follows:
import random #this generates a random int from 1-100, inclusive secretNum = random.randint(1,100)
Example output:
Welcome to the guessing game. You need to guess a number from 1 to 100. What is your guess? 50 Guess is too low. What is your guess? 75 Guess is too low. What is your guess? 87 Guess is too high. What is your guess? 81 Guess is too low. What is your guess? 84 Guess is too low. What is your guess? 85 Congratulations! You guessed the secret number in 6 guesses!
Update the Unit B Counting and Finding In-Class exercise to use a loop.
Believe you can and you're halfway there.
" to a variable called quote
(this is a quote from Theodore Roosevelt).
Hint: One way is to loop a fixed number of times, based on the count of the "a" characters.
Another way is to loop until you have searched the entire string.
It can be convenient to initialize the location variable before starting the loop.
Write a script using nested for loops to generate a triangular multiplication table as illustrated below.
Ask the user how many rows they would like in their table.
Generate formatted output where each number is right justified within a fixed field size, so that the numbers in each column are aligned.
Test with a user value of 12 rows.
Example output:
a found at index 13 a found at index 16 a found at index 28 a found at index 32 Please enter the number of rows for the multiplication table: 12 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 and so on...
Add the following at the end of the script to show your results:
'''
Execution results:
paste execution results here
'''
Submit all three of your finished py scripts in Canvas, Problem E.