Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. def display():
  2. print("Funtion")
  3. print("Inside the Function")
  4.  
  5. display()
  6.  
  7.  
  8. def calcSum(x, y):
  9. total = x + y
  10. print(total)
  11.  
  12. calcSum(3, 4)
  13. calcSum(10, 20)
  14.  
  15. def show_local():
  16. x = 10
  17. print(x)
  18. y = x * 2
  19. print(y)
  20. show_local()
  21.  
  22.  
  23.  
  24. def calc():
  25. x = 10
  26. y = 5
  27. return x, y
  28.  
  29.  
  30. y, x = calc()
  31. print(y, x)
  32.  
  33. ############################
  34.  
  35. def factorial(n):
  36. fac = 1
  37. for number in range(1, n+1):
  38. fac = fac * number
  39. return fac
  40.  
  41. result = factorial(10)
  42.  
  43.  
  44. keepGoing = "yes"
  45. while keepGoing == "yes":
  46. number = eval(input("number: "))
  47. keepGoing = input("Enter yes to continue: ")
  48.  
  49.  
  50. number = eval(input("Enter a positive number or 0 to stop: "))
  51.  
  52. while number != 0:
  53. print(number)
  54. number = eval(input("Enter a positive number or 0 to stop: "))
  55.  
  56.  
  57.  
  58. def calcSum():
  59. keepGoing = "yes"
  60. total = 0
  61. while keepGoing == "yes":
  62. num = eval(input("Enter a number: "))
  63. total = num + num
  64. keepGoing = input("Enter yes to continue: ")
  65. return total
  66.  
  67. total = calcSum()
  68. print(total)
  69.  
  70.  
  71.  
  72. def findMax():
  73. maxValue = 0
  74. number = eval(input("Enter a positive number or 0 to quit: "))
  75. while number != 0:
  76. if number > maxValue:
  77. maxValue = number
  78. number = eval(input("Enter a positive number or 0 to quit: "))
  79. return maxValue
  80.  
  81. total = findMax()
  82. print(total)
  83.  
  84.  
  85. import math
  86.  
  87. def area(radius):
  88. result = math.pi * radius ** 2
  89. return result
  90.  
  91. import random
  92.  
  93. def randomNumber():
  94. countEven = 0
  95. coundOdd = 0
  96. for time in range(100):
  97. x = random.randint(10, 20)
  98. if x % 2 == 0:
  99. countEven += 1
  100.  
  101. else:
  102. countOdd += 1
  103. return countEven, countOdd
  104.  
  105. x, y = randomNumber()
  106. print(x,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement