Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The highlighted part is the question... The code i have below is incorrect... wo variables, x and y, supposedly hold strings of digits. Write code

The highlighted part is the question... The code i have below is incorrect...

image text in transcribed

wo variables, x and y, supposedly hold strings of digits. Write code that converts these to integers and assigns a ariable z the sum of these two integers. Make sure that if either x and y has bad data (that is, not a string of digits), z will be assigned the value of -1 X 6 of 6: 2018-11-06 01:29:57- W SUBMIT 1 # string of digits 2 x = '456' 4 # string of digits 5 y 789 6 7 # check whether the variable x and y contains integer values or not 8 if (str.isdigit(x) and str.isdigit(y)): 9 10 11 mpx-int(x) 12 13 14 tmpY = int (y) 15 16 17 18 19 # If x and y contains bad data 20 else: 21 # Convert the x value into integer # Convert the y value into integer # sum of x and y # assign value of z as "-1" 23 24 25 print('Not a string of digits') 26 27 #Display the result on the screen 28 print( 'Sum is ',z)

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions