Advertisement
Guest User

Introduction to Python

a guest
Feb 3rd, 2020
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. print("Hello World!")
  2.  
  3. # print(345657**356)
  4.  
  5. # a = int(input("Number to * by 4 "))
  6. # b = 4
  7.  
  8. # c = a * b
  9.  
  10. # str = "{}*{} = {}".format(a, b, c)
  11.  
  12. # # These lines do the same thing!
  13. # print(str)
  14. # print(a, "*", b, "=", c)
  15.  
  16. # DO NOT REMOVE THIS LINE - I don't know why, but the program breaks if you do
  17.  
  18.  
  19. # n = 15
  20.  
  21. # if n % 3 == 0:
  22. #   print("Fizz\n")
  23. # if n % 5 == 0:
  24. #   print("Buzz")
  25. # print()
  26. # print(n)
  27.  
  28. def isMultipleOf3(n):
  29.   return n % 3 == 0
  30.  
  31. def isMultipleOf5(n):
  32.   return n % 5 == 0
  33.  
  34. def FizzBuzz(maxValue):
  35.   for n in range(1, maxValue):
  36.     if isMultipleOf3(n) and isMultipleOf5(n):
  37.       print("FizzBuzz")
  38.     elif isMultipleOf3(n):
  39.       print("Fizz")
  40.     elif isMultipleOf5(n):
  41.       print("Buzz")
  42.     else:
  43.       print(n)
  44.  
  45. print()
  46. # print(isMultipleOf3(3))
  47. # print(isMultipleOf3(5))
  48.  
  49. # FizzBuzz(15)
  50.  
  51. # FizzBuzz(26677)
  52.  
  53. # x = input("Give me a number: ")
  54. # x = int(x)
  55.  
  56. # FizzBuzz(x)
  57.  
  58.  
  59.  
  60. listOfCourses = ["English", "Linguistics", "Computer Science"]
  61.  
  62. print(listOfCourses)
  63.  
  64. listOfCourses.append("Biology")
  65.  
  66. print(len(listOfCourses))
  67.  
  68. for course in listOfCourses:
  69.   print("LU teaches", course)
  70.  
  71.  
  72.  
  73. nums = [1, 2, 3, 4, 5]
  74.  
  75. for n in nums:
  76.   print(n *3)
  77.  
  78.  
  79. # numsTimes4 = [x for x in range(1, 15): x * 4]
  80.  
  81. import random
  82.  
  83. print(random.random())
  84.  
  85.  
  86.  
  87. # I go to Washington
  88. # ["I", "go", "to", "Washington"]
  89.  
  90. # Mr. Smith goes to Washington. I went last year...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement