Question

In: Computer Science

Intro to Python! 1. Using while loops, write a program that prints multiples of 5 which...

Intro to Python!

1. Using while loops, write a program that prints multiples of 5 which are less than 100. Your loop initially starts from 0.

2. Consider B to be a list of alphabetically ordered strings. Using while loops, write a program that only prints words which start with letter A.

B = [Alex, Airplane, Alpha, Australia, Ben, Book, Bank, Circuit, Count, Dark]

3. Using while loop, create a program that only prints first 18 multiples of 7.Hint: Your loop initially starts from 1. You should create a counter to keep track!

Solutions

Expert Solution

Solution

1)

code

i = 0
while i < 100:
if i%5==0 and i!=0:
print(i)
i=i+1

Screenshot

Output

---

2)

Solution

Code

B = ['Alex', 'Airplane', 'Alpha', 'Australia', 'Ben', 'Book', 'Bank', 'Circuit', 'Count', 'Dark']
length = len(B)
i = 0
# Iterating using while loop
while i < length:
if B[i].startswith('A'):
print(B[i])
i += 1

Screenshot

Output

---

3)

Code

i = 1
while i <=18:
print(i*7)
i=i+1

Screenshot

Output

---

all the best


Related Solutions

Code in Python. You can only use while loops NOT for loops. Program 1: cost_living In...
Code in Python. You can only use while loops NOT for loops. Program 1: cost_living In 2020 the average cost of living/month (excluding housing) for a family of 4 in Pittsburgh was $3850 per month. Write a program to print the first year in which the cost of living/month is over $4450 given that it will rise at a rate of 2.1% per year. (Note:  this program requires no input). Program 2: discount A discount store is having a sale where...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out your name and PRINTS OUT any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and PRINTS OUT a message telling if the numberer is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one parameter, a number,...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a sentinel value #This while loop ends when the user enters a 1, the sentinel value #Assign the number 8 to a variable which will serve as the sentinel value #Condition: while variable is not equal to 1 #Action: display the number assigned to the variable #Use an input statement (no prompt) to ask the user for a number and assign this number to the...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
In python write a program which prints the longest substring of numbers which occur in ascending...
In python write a program which prints the longest substring of numbers which occur in ascending order s=342153476757561235
Write a program using python that loops over each file in a specified directory and checks...
Write a program using python that loops over each file in a specified directory and checks the size of each file.You should create 2-tuple with the filename and size, should append the 2-tuple to a list, and then store all the lists in a dictionary.  
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints...
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints the sum of the even and odd integers. 2.) Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)
Write a PYTHON program that uses a while loop to prompt for 5 integers. If the...
Write a PYTHON program that uses a while loop to prompt for 5 integers. If the number is equal to 99, display "Ninety-nine", otherwise display "no-match". If the number is equal to 75, display "Seventy-five", otherwise display "no-match".
Write a python code which prints triangle of stars using a loop ( for loop )...
Write a python code which prints triangle of stars using a loop ( for loop ) Remember what 5 * "*" does The number of lines of output should be determined by the user. For example, if the user enters 3, your output should be: * ** *** If the user enters 6, the output should be: * ** *** **** ***** ****** You do NOT need to check for valid input in this program. You may assume the user...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT