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

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 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...
Create a python program that prints the series from 5 to 500.
Create a python program that prints the series from 5 to 500.
Python Language: Similar to Project 3, write a program that loops a number from 1 to...
Python Language: Similar to Project 3, write a program that loops a number from 1 to 10 thousand and keeps updating a count variable according to these rules: if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if none of the above conditions match for the number, increase count by the number. Before the loop begins,...
In C program, Use "do...while" and "for" loops to write a program that finds all prime...
In C program, Use "do...while" and "for" loops to write a program that finds all prime numbers less than a specified value.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT