Question: python 16.16 Lab 3 Part D: Guess the Data Type When we read values using the input command, they always start as strings If we

python

python 16.16 Lab 3 Part D: Guess the Data Type When we

16.16 Lab 3 Part D: Guess the Data Type When we read values using the input command, they always start as strings If we try to convert a string to an integer or a float and the conversion fails, an error will be thrown. Specifically, a value error. We can catch this error using an except statement. The following example shows an error being caught. try: x int("Not a Number") except ValueError as e: print("Error:", e) If the code is executed, it will print Error: invalid literal for int) with base 10: 'Not a Number' For this part of the lab, ask the user for an input and use try/except statements to determine if the data is an integer, float, or string. The interface should match the following examples. Welcome to Type Guesser Enter Something: You entered an integer! Value: 9 Welcome to Type Guesser Enter Something: 12.9 You entered a float! Value: 12.9 Welcome to Type Guesser Enter Something: Oranges You entered a string! Value: Oranges Welcome to Type Guesser Enter Something: 12.9 Oranges You entered a string! Value: 12.9 Oranges LAB ACTIVITY 16.16.1: Lab 3 Part D: Guess the Data Type 0/4 main.py

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!