Challenges 6
Challenges 6
6a). Get the user to enter a sentence and:
Low: Using a count controlled loop (for loop, cant use built in python commands) count how many vowels are in the text.
Sentence: Alright everyone!
Vowels: 6
Med: Make the text print out with alternating lower and upper case characters.
Use commands .lower() and .upper()
Sentence: Alright everyone!
Vowels: 6
AlRiGhT EvErYoNe!
High: Print out each word in the sentence one at a time. Using no built in functions. Add each letter one at a time to a new variable. Then looks for the moment there is a space and print out the variable, make sure you set it blank after.
Sentence: Alright everyone!
Vowels: 6
AlRiGhT EvErYoNe!
Alright
Everyone!
6b). Get the user to enter a sentence and:
High: You can assume all lower case text.
Perform a Caesar Shift of the data by 2 to the right.
Super High:
Get the user to enter the number to shift right by (max 25) and then perform the shift on either upper or lower case letters.
Enter Shift:3
Enter Sentence:Hello
Khoor
6c). Array challenges:
Low: Copy the array below into python then get the user to enter a name and see if it is in the array. It should print out the name and where it was found.
Names=["Steve","Mary","Mohammed","Graham","Tamilore","Candice","Bob","Lisa"]
Enter Name: Mary
Found at position 1.
Med:
Copy the array below into python then calculate the min, max and average numbers.
Numbers= [1,4,7,8,9,1,3,4,2,5,6]
High:
Start off with a blank array then get the user to enter numbers until they enter nothing.
Note: You will have use input without casting to an int as you need to check if they entered a blank string. You can always cast the number later (see below):
number=input("Enter an number of blank to finish:"
if number="": #do something
number=int(number) # turn number into an integer after we check for blank.
Numbers= []
To add an item to an array do:
Numbers.append(5)