Advertisement
timber101

Gimme5 - TraceTables

Feb 19th, 2022
695
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None
  1. """
  2. ORIGINAL
  3. Use the trace table below to help you answer (a), (b) and (c) below.
  4. What would be the values of integer variables x, y and z after execution of
  5. these statements if the initial values of x and y are
  6.  
  7.         (a) 2 and 7    
  8.         (b) -4 and -4  
  9.         (c) 27 and 3   
  10.  
  11.     z = x
  12.     IF x = y THEN
  13.         x = x * x
  14.         y = (x + y) / 2
  15.     ELSE
  16.         IF x < y THEN
  17.             y = y * y
  18.             z = y - x
  19.         ELSE
  20.             IF x > 0 THEN
  21.                 z = x/y
  22.             ENDIF
  23.         ENDIF
  24.         y = 200
  25.     ENDIF
  26.     OUTPUT x, y, z 
  27. """
  28. # Trace Tables
  29. """
  30. Use the trace table below to help you answer (a), (b) and (c) below.
  31.     What would be the values of integer variables x, y and z after execution of these statements if the initial values of x and y are
  32.  
  33.         (a) 2 and 7    
  34.         (b) -4 and -4  
  35.         (c) 27 and 3
  36. ####
  37. CONVERTED
  38. ####   
  39. """
  40. x = int(input("Enter number"))
  41. y = int(input("Enter number"))
  42. z = x
  43. if x == y:
  44.     x = x * x
  45.     y = (x + y) / 2
  46. else:
  47.     if x < y:
  48.         y = y * y
  49.         z = y - x
  50.     else:
  51.         if x > 0:
  52.             z = x/y
  53.     y = 200
  54. print( x, y, z)
  55.    
  56.  
  57.  
Advertisement
RAW Paste Data Copied
Advertisement