Python My ITlab:
1. Write some code that repeatedly reads a value into the variable n until a number between 1 and 10 (inclusive) has been entered.
2. Write some code that repeatedly reads a value from standard input into the variable response until at last a Y or y or N or n has been entered.
3.Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, each on a separate line, The loop terminates when it reads an integer that is not positive.
4.Write a loop that reads positive integers from standard input, printing out those values that are even, each on a separate line. The loop terminates when it reads an integer that is not positive.
Solution:
1Problem:
Code:
# this loop will iterate till n is in between 1 to 10
inclusive
while(True):
# to except any conversion errors
try:
n = int(input(""))
if(n>=1 and
n<=10):
break
except:
pass
Image:
SampleOutput:
2ndProblem:
Code:
# loop will iterate till response is equal to Y or y or N or
n
while(True):
try:
response =
input("")
if(response == "Y" or
response == "y" or response == "N" or response == "n"):
break
except:
pass
SampleOutput:
3rdProblem:
Code:
# loop to read values till input value is negative
while(True):
try:
n = int(input(""))
# if n is less than 0
break the loop
if(n < 0):
break
# if n is greater than
100 print n
if(n > 100):
print(n)
except:
pass
SampleOutput:
4thProblem:
Code:
# loop will iterate till input value is negative
while(True):
try:
n = int(input(""))
if(n < 0):
break
# print n if n is even
number
if(n%2 == 0):
print(n)
except:
pass
SampleOutput:
Python My ITlab: 1. Write some code that repeatedly reads a value into the variable n...
python 3 please, for these questions you do not need to write the whole code just the expression 1)Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, each on a separate line, The loop terminates when it reads an integer that is not positive. 2) Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop...
Given an int variable n that has already been declared, write some code in C that repeatedly reads a value into n until at last a number between 1 and 10 (inclusive) has been entered.
Please use Python to solve this problem: Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out, on a single line and separated by a single space, the sum of all the even integers read and the sum of all the odd integers read.
C++ Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out the sum of all the even integers read and the sum of all the odd integers read(The two sums are separated by a space). Declare any variables that are needed.
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
Part A Write a Java program that reads an integer n from the keyboard and loops until −13 ≤ n ≤ 13 is successfully entered. A do-while loop is advised. Part B Write a Java program that reads an integer n from the keyboard and prints the corresponding value n!. [This is n factorial]. You must verify that the input integer satisfies the constraint 0 ≤ n ≤ 13; keep looping until the constraint is satisfied. Will give thumbs up...
Using a Python environment, complete two small Python programs - Write a function which repeatedly reads numbers until the user enters “done” Once “done” is entered, print out the sum, average, maximum, and minimum of the values entered If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. 2. Write another function so that it draws a sideways tree pointing right; for example,...
Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered. To get proper credit, name the variables as listed below and follow the directions carefully. Do not use any break or similar type of statements. To implement the above code, you will need to count the entries - name the counter variable num_count. You will also need to use a variable,...
Python Use the Design Recipe to write a function called running_average that repeatedly asks the user to input integers at the keyboard until they type the word done. Return the average of the values they entered. You may assume the user will only enter integers or "done". Include a docstring!
Write a fragment of code that reads in a header value from the standard input and then reads in that many integers (also from standard input) and prints their sum to standard output (for loops, header values, accumulators, basic arithmetic). Declare any variables you use. part b Objects of the Calculator class require no additional information when created. Define an object named calc, of type Calculator.