Question: using python !! Exercise 1: Given a budget of $100 and a ticket price of $7, use a while loop to calculate how many tickets
using python !!
Exercise 1: Given a budget of $100 and a ticket price of $7, use a while loop to calculate how many tickets can be purchased with the total dollar amount staying within the budget. The code in the loop can add the price of one ticket to a total, and increment a count of the number of tickets. Hint: you may need to use a break statement to exit the loop early if the next iteration would send the total over the budget amount.
Exercise 2: Given a string, alphabet = "abcdefghijklmnopqrstuvwxyz", use a loop to have each letter in the string print on a different line. Edit: It's OK to use either a for or while loop.
Exercise 3: Use the same alphabet, but this time have the loop print a slice of 2 letters from the string on each different line. For example, ab on the first line, cd on the second line, etc. Edit: It's OK to use a for or while loop.
Exercise 4: Write a function that takes two parameters, a single letter and a word. Use a loop to iterate through the word and count how many times the single letter appears in the word. Have the function return the value of the count. So if the letter being searched were 'n' and the word were 'banana', the function should return the value of 2, because there are two 'n' characters in 'banana'.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
