Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. 2. Answer in Python. Use the given code in the answer Given the example output, write code that will generate this output. Note: do

1.image text in transcribed

2.

image text in transcribedAnswer in Python. Use the given code in the answer

Given the example output, write code that will generate this output. Note: do not use input(). Note: the values after the colons in the output ':' must be generated by either a function or formula (expression). = In [22]: num_int num str = 123 "456" Data type of num_int: Data type of num_str before Type Casting: Data type of num_str after Type Casting: Sum of num int and num str: 579 Data type of the sum: Modify the below program to satisy the following requirements: When a ValueError is raised, the program will display this message: Not a number! When an AssertionError is raised, the program will display this message: Not an even number! When no exception is raised, the program will display the reciprocal of the number entered. Your program must include the following keywords: assert, try, except, else. . Note: A ValueError is raised when a user types in data of an inappropriate type. Note: An AssertionError is raised when a user types in numeric data that is not even. Note: Use the modulus operator, sometimes also called the remainder operator, to determine whether an input number is either even or odd. Note: Do not include in the assert statement a condition; instead, however, 'catch' the exception using except. Note: Additional references on Python's assert statement: https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python In [1]: try: num = int(input("Enter an even number: ")) assert num% 2 == 0 except ValueError: Enter an even number: 9 Not an even number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Differentiate between hard and soft measures of service quality.

Answered: 1 week ago

Question

Be familiar with the different perspectives of service quality.

Answered: 1 week ago