Question

In: Computer Science

PUT IN PYTHON LANGUAGE CODE # Write one while-loop that starts at 500 and prints every...

PUT IN PYTHON LANGUAGE CODE

# Write one while-loop that starts at 500 and prints every 6th number down to 300
# (i.e., prints 500, 494, 488, . . . etc., but does not print any number lower than 300).

# Write one while-loop that starts at 80 and prints every 12h number thereafter,
# but does not print any number greater than 210

# Write one while-loop that prints all the numbers from 30 through 70,
# except for the numbers 41 and 57.

# Write one while-loop that prints the sum of all the even numbers
# (50, 52, 54, . . . etc.,) from 50 through 2000.

# Write one while-loop that prints the count of all the numbers
# from 20 through 2500 that are divisible by 9
# (in other words prints out how many numbers are divisible by 9).

Solutions

Expert Solution

# Write one while-loop that starts at 500 and prints every 6th number down to 300
# (i.e., prints 500, 494, 488, . . . etc., but does not print any number lower than 300).
i = 500
while i > 300:
   print(i, end = ' ')
   i -= 6
print()


# Write one while-loop that starts at 80 and prints every 12h number thereafter,
# but does not print any number greater than 210
i = 80
while i < 210:
   print(i, end = ' ')
   i += 12
print()


# Write one while-loop that prints all the numbers from 30 through 70,
# except for the numbers 41 and 57.
i = 30
while i <= 70:
   if i != 41 and i != 57:
      print(i, end = ' ')
   i += 1
print()


# Write one while-loop that prints the sum of all the even numbers
# (50, 52, 54, . . . etc.,) from 50 through 2000.
i = 50
sum_even = 0
while i <= 2000:
   sum_even += i
   i += 2
print(sum_even)


# Write one while-loop that prints the count of all the numbers
# from 20 through 2500 that are divisible by 9
# (in other words prints out how many numbers are divisible by 9).
i = 20
count = 0
while i < 2500:
   if i % 9 == 0:
      count += 1
   i += 1
print(count)

FOR HELP PLEASE COMMENT.
THANK YOU


Related Solutions

Code in python Write a while loop code where it always starts form 2. Then it...
Code in python Write a while loop code where it always starts form 2. Then it randomly chooses a number from 1-4. If the number 4 is hit then it will write “TP” if the number 1 is hit then it will write”SL”. It will rerun the program every time the numbers 1 and 5 are hit. The code should also output every single number that is randomly chosen. 2 of the same numbers can't be chosen back to back...
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...
java language question: Write a thread that continuously prints a message every 100 milliseconds while it...
java language question: Write a thread that continuously prints a message every 100 milliseconds while it is still alive. The thread should be written in such a way that it can be terminated at any time by a control program (main).
every code should be in java Program 1: Write a while loop that sums the integers...
every code should be in java Program 1: Write a while loop that sums the integers from 1 to 10, excluding 3 and 6. Print the sum. [Hint: Use logical operators] Program 2: Write a for loop that attempts to display the numbers from 1 to 10, but terminates when the control variable reaches the value 6. Program 3: Write a do...while loop that prints the integers from 10 to 0, inclusive.
Create Python Code using a "for" loop and a "while" loop. You are starting a twelve...
Create Python Code using a "for" loop and a "while" loop. You are starting a twelve week program training to compete in a triathlon. The triathlon consists of three athletic events, 1.5 k swim, 40k bike, 10k run. In order to be prepared for the competition you want to print a training schedule. Starting with week 1 you will increase the distance of each activity so that you reach the race distance by week twelve. Due to rounding, you may...
Important: please use python. Using while loop, write python code to print the times table (from...
Important: please use python. Using while loop, write python code to print the times table (from 0 to 20, incremented by 2) for number 5. Add asterisks (****) so the output looks exactly as shown below.   Please send the code and the output of the program. ****************************************************************** This Program Shows Times Table for Number 5 (from 0 to 20) Incremented by 2 * ****************************************************************** 0 x 5 = 0 2 x 5 = 10 4 x 5 = 20 6...
Using Python programming language, write a LONG piece of code that utilizes the do while function...
Using Python programming language, write a LONG piece of code that utilizes the do while function and the switch statement, please do not make It short, thank you.
*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 loop that goes through the list and prints each string where the string...
Write a Python loop that goes through the list and prints each string where the string length is three or more and the first and last characters of the strings are the same. Test your code on the following three versions of the list examples: examples = ['abab', 'xyz', 'aa', 'x', 'bcb'] examples = ['', 'x', 'xy', 'xyx', 'xx'] examples = ['aaa', 'be', 'abc', 'hello'].
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT