Question: 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...

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

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

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!