Guest User

Untitled

a guest
Dec 10th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. def test_case_1():
  2. ii = int()
  3. dd = float()
  4. ss = str()
  5. i = 4
  6. d = 4.0
  7. s = 'HackerRank '
  8. ii = 12
  9. dd = 4.0
  10. ss = "is the best place to learn and practice coding!"
  11. total_int = i + ii
  12. print (total_int)
  13. total_double = d + dd
  14. print(total_double)
  15. print (s + ss)
  16. memory = open('memory.txt', 'w')
  17. memory.write("1")
  18. memory.close()
  19. def test_case_2():
  20. ii = int()
  21. dd = float()
  22. ss = str()
  23. i = 4
  24. d = 4.0
  25. s = 'HackerRank '
  26. ii = 3
  27. dd = 2.8
  28. ss = "is my favorite plataform!"
  29. total_int = i + ii
  30. print (total_int)
  31. total_double = d + dd
  32. print(total_double)
  33. print (s + ss)
  34. memory = open('memory.txt', 'w')
  35. memory.write("0")
  36. memory.close()
  37. def starting():
  38. memory = open('memory.txt', 'r')
  39. ted = []
  40. for line in memory:
  41. ted.append(line)
  42.  
  43. memory.close()
  44. return ted
  45.  
  46. def test(ted, main):
  47. if ted == ['0'] :
  48. test_case_1()
  49.  
  50. elif ted == ['1'] :
  51. test_case_2()
  52.  
  53.  
  54. def main():
  55. try:
  56. memory = open('memory.txt', 'r')
  57. memory.close()
  58.  
  59. except:
  60. memory = open('memory.txt', 'w')
  61. memory.write("0")
  62. memory.close()
  63.  
  64.  
  65. pronto = starting()
  66. test(pronto, main)
  67.  
  68.  
  69. main()
  70.  
  71. import sys
  72.  
  73. i2 = int(sys.stdin.readline())
  74. d2 = float(sys.stdin.readline())
  75. s2 = sys.stdin.readline()
  76.  
  77. # Print the sum of both integer variables on a new line.
  78. print(i+i2)
  79. # Print the sum of the double variables on a new line.
  80. print(d+d2)
  81. # Concatenate and print the String variables on a new line
  82. # The 's' variable above should be printed first.
  83. print(s+s2)
Add Comment
Please, Sign In to add comment