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
What do you think will happen if you use a different file format for a certain document type?
sweet-ann [11.9K]

Answer:

It will either convert the file automatically into the program so you can edit it on the different platform or it will not be able to open the document at all.

Explanation:

I have personally done this before. Usually I use Word documents, which are .doc and .docx files.

I also run a Linux based OS sometimes (dual boot) and I don't have Microsoft Office products on it. However, Linux does have their own set of products that are similar to it.

I opened a .docx file on the Linux version of Word and it did convert the file into a separate one and I was able to edit it.

However, when I then tried opening the new Linux file type on Word, it was not able to open the document at all.

Therefore, it really depends on what programs have what capabilities. Word can open .doc and .docx. Linux could open their own types as well as .doc and .docx by conversion.

A rule of thumb is just not to change the file format at all. Just stick with the original so you don't lose your file. If you cannot do so, then use a online file converter to change the file type.

3 0
3 years ago
QUESTION 7
marishachu [46]
False, it needs to be properly cited because that is plagiarism which is illegal
6 0
3 years ago
HELP PLEASE!!! Which development method is best explained in this way: a creation of a prototype model that will eventually be d
DerKrebs [107]

Answer:

Not sure but I think its Rapid Prototyping Method

4 0
3 years ago
What do you click to create a new presentation in noral view
stepladder [879]
Go to the top left of the page, there you will see "file" click it and click new:)
4 0
3 years ago
Which situations are most likey to use Telehealth
Scilla [17]

Answer:

Emergency situations that make it difficult to go to a clinic will likely require Telehealth. Examples include cases of

1. heart attack

2. breathing difficulties

3. health challenges that begin in the night

4. onset of child labor

5. a pandemic situation where hospitals are filled up

6. sickness among aged people in rural communities with no clinic, etc.

Explanation:

Summarily, the World Health Organization (WHO) defines Telehealth as the 'incorporation of Information Communication Technology in the delivery of health care services in situations where patients and health care providers are separated by distance'. Emergency health situations that make it difficult to quickly access medical help can benefit from Telehealth.

In the cases of a pandemic such as the one experienced in 2020, where hospitals were filled to the brim, telehealth proved to be a useful form of health care delivery.

4 0
3 years ago
Other questions:
  • The cmos memory located on the motherboard is often referred to as _____ memory because of its capability to store bios settings
    9·1 answer
  • ________ software provides a means of sharing, distributing, and searching through documents by converting them into a format th
    13·1 answer
  • PowerPoint’s _____ feature can assist you in finding answers to questions such as “How can I specify which slides to print?” a.
    6·1 answer
  • Define data, explain its three forms, and the general steps a computer performs related to data.
    7·1 answer
  • What will the following segment of code output if 11 is entered at the keyboard?
    12·1 answer
  • What are the advantages of using the internet as theinfrastructure for electronic commerce and electronicbusiness?
    6·1 answer
  • Write a program that use a switch statement whose controlling expression is the variable area code. If the value of area_code is
    12·1 answer
  • Write a C++ Win32 Console Application that will use nested for loops to generate a multiplication table from 1 x 1 to 10 x 10. U
    12·1 answer
  • Someone receives and email that appears to be from their bank requesting them to verify account information, this type of attack
    10·1 answer
  • What is a non-example for job application???
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!