1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sukhopar [10]
3 years ago
11

Write a program using Python that prompts for an integer and prints the integer, but if something other than an integer is input

, the program keeps asking for an integer. Here is a sample session:
Input an integer: abc

Error: try again.

Input an integer: 4a

Error: try again.

Input an integer: 2.5

Error: try again.

Input an integer: 123

The integer is: 123
Computers and Technology
2 answers:
Tcecarenko [31]3 years ago
7 0

Answer:

#program in Python

#read until user Enter an integer

while True:

   #try block to check integer

   try:

       #read input from user

       inp = int(input("Enter an integer: "))

       #print input

       print("The integer is: ",inp)

       break

   #if input is not integer

   except ValueError:

       #print message

       print("Wrong: try again.")

Explanation:

In try block, read input from user.If the input is not integer the print a message  in except block.Read the input until user enter an integer. When user enter an  integer then print the integer and break the loop.

Output:

Enter an integer: acs                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 4a                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 2.2                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 12                                                                                                      

The integer is:  12  

trasher [3.6K]3 years ago
3 0

Answer:

Enter an integer: 4a                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 2.2                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 12                                                                                                      

The integer is:  12  

hope this helps

You might be interested in
When using linear or reciprocal navigation, what should be the interface include?
Alex_Xolod [135]
The answer to the question is A
5 0
3 years ago
A(n) _____ is similar to a virus, except that it is an independent program that can be spread across computer networks without b
CaHeK987 [17]
The term you're looking for is worm
5 0
3 years ago
Intel® Core™ i5-7500 is one of Intel's 7th generation of microprocessors and was launched earlier in 2017 and has been used in m
Ket [755]

Answer:

A. 4 CPUs and 6 megabyte cache memory

B. 1.3157 x10^-9 nanoseconds

Explanation:

The Intel core i5 7500 is a seventh generation central processing unit with a 4 CPU core and a 6 megabyte cache memory. It executes task at a clock cycle of 5 clock cycle at a speed of 3.8 GHz.

The relationship between frequency and clock cycle is,

Clock cycle = 1 / ( frequent).

So, One clock cycle = 1 / 3.8 GHz

= 0.3 x10^-9

For five clock cycles = 5 x 0.3 x10^-9

= 1.3157 x10^-9 nanoseconds.

5 0
3 years ago
Which two graphs best represent the motion of an object falling freely?
larisa [96]
The graph would have to be pointing completely down to be falling freely.
4 0
3 years ago
Does excel have more than 400 functions
castortr0y [4]
Yes excel has more than 400 functions
7 0
3 years ago
Other questions:
  • All of the following are the four more widely social media networks discussed in the text EXCEPT:
    11·2 answers
  • What software development model focuses on improving the product in small steps each time through the cycle?
    14·2 answers
  • Ten members of a wedding party are lining up in a row for a photograph.
    8·1 answer
  • In the event you get pulled over for a traffic stop, describe the situation from the police officer's perspective and list at le
    6·2 answers
  • Please help I really need it :(
    12·1 answer
  • A radio and communications security repairer is responsible for both radio and satellite communication systems.
    6·2 answers
  • Convertbinary(111100)to decimal​​​​
    13·2 answers
  • How to use emojis on chromebook without on-screen keyboard
    14·1 answer
  • There is overlap in the subjects of study in the different information technology disciplines. true or false
    15·1 answer
  • which two partitions do you typically create at minimum during a fedora linux installation? (choose two answers.)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!