Question

In: Computer Science

Write a Python program that has a loop to continuously ask the user for a number,...

Write a Python program that has a loop to continuously ask the user for a number, terminating the loop when the number entered is -1.

Inside the loop,

1.) display one asterisk(*) if the number is 1,

2.) two asterisk(**) if the number is 2 and

3.) "OTHER" if the number is any other number.

Solutions

Expert Solution

PYTHON PROGRAM :-

num = int(input("Please enter a number and -1 to stop \n"));
while num!=-1:
if num == 1:
print('*')
elif num == 2:
print('**')
else:
print("OTHER")
  
num = int(input("Please enter a number and -1 to stop \n"));

Output with program indentation screenshot :-


Related Solutions

In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
USE MATLAB Write a program in Matlab that would continuously ask the user for an input...
USE MATLAB Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “Mahahanap mo na ang forever mo. Sana all!” If the user’s die is smaller, it should display, “Gising na friend,...
Write a program that uses a while loop with a priming read to ask the user...
Write a program that uses a while loop with a priming read to ask the user to input a set positive integers. As long as the user enters a number greater than -1, the program should accumulate the total, keep track of the number of numbers being entered and then calculate the average of the set of numbers after the user enters a -1. This is a sentinel controlled-loop. Here is what a sample run should look like: Enter the...
In python Write the code to ask a user to enter a number in the range...
In python Write the code to ask a user to enter a number in the range of 1-100. Have the code checked to make sure that it is in this range. If it is not, let the user re-enter the number. The user should be able to re-enter numbers until the number is within the correct range.
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...
Python Program Write a program that will ask a user on how many input colored balls...
Python Program Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.
in java Write a while loop to ask the user to type number of hours(double) they...
in java Write a while loop to ask the user to type number of hours(double) they work per day. Calculate and print the salary for each valid input. If number of hours is greater than or equal to 0 and less than 5, then:  salary = numberofhours * 5, loop continues, the user can type another number If number of hours is greater or equal to 5, and less than 10, then: salary = numberofours * 8, loop continues, the user...
Write a program will ask the user for the annual income and the number of years...
Write a program will ask the user for the annual income and the number of years that the user has worked as their current job. The program will tell the user whether or not he or she qualifies for a loan based on the following condition: income is equal to or exceeds $35,000 or number of years on job is greater than 5 Do not use “nested if statements” in your solution. As an example of the output: What is...
Python Programming Please! #Name: #Date: #Random number, loop while true #ask user for number. Check to...
Python Programming Please! #Name: #Date: #Random number, loop while true #ask user for number. Check to see if the value is a number between 1 and 10 #if number is too high or too low, tell user, if they guessed it break out of loop Display "Welcome to my Guess the number program!" random mynumber count=1 while True try Display "Guess a number between 1 and 10"   Get guess while guess<1 or guess>10 Display "Guess a number between 1 and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT