4/8/2020 Pastebin.com - Printed Paste ID: https://pastebin.
com/i6eSqqyW
1. #COMMENTS:
2. #This is the second comment
3. a = 1 #and this is the third comment
4. text = "# This is not a comment because it's inside quotes."
5.
6. #print displays a string
7. #strings can be within single or double quotation marks
8. #we will use double quotation marks in class
9. print("Welcome to Python!") #same as print('Hello Python!')
10. print() #leave a blank line
11.
12. #input function
13. name = input("What is your name? ")
14. print("Hello", name)
15.
16. calc = input("Enter a calculation: ")
17. print(eval(calc))
18.
19. input("Press any key to continue...")
20.
21. #NUMBERS:
22. print("NUMBERS:")
23. #The interpreter acts a a simple calculator when working with numbers
24. # +,-,*,/ are basic operators
25.
26. #datatypes: integer, float, complex, string, boolean
27. #whole numbers (1, 2, 18, etc) have datatype int
28. #numbers with a fractional part are type float
29.
30. #datatype in front of arg performs conversion
31.
32. print(5*3)
33. print(2**6) #powers
34. print(50-5*6)
35. print((50-5*6)/4) #divide always produces a float
36. print(8/3)
37. print(round(8/3,2)) #round off numbers
38. print()
39. print(13 / 5)
40. #floor division ( // ) returns an integer result
41. print(13 // 5) #floor division
42. print(-13 // 5)
43. #modulus - remainder from a division
44. print(17 % 3)
45. print()
46.
47. #VARIABLES:
48. #forcing a datatype
49. s = str(input("Enter your name: "))
50. x = int(input("Enter a whole number: "))
51. f = float(input("Enter a number: "))
52.
53. print()
54. print("Hello", s)
https://pastebin.com/print/i6eSqqyW 1/2
4/8/2020 Pastebin.com - Printed Paste ID: https://pastebin.com/i6eSqqyW
55. print("Your whole number was", x)
56. print("Your floating point number was", f)
57.
58. print("VARIABLES:")
59. fHeight = 3.53
60. fWidth = 2.47
61. fArea = fHeight * fWidth
62. print(fArea)
63. print("Area =", fArea)
64. print("Area = {:.3f}".format(fArea))
65. print()
66. #using a variable that has not been assigned a value will give an error
67.
68. #The last displayed expression is assigned to the variable _ automatically
69. #The _ variable can be used to continue a calculation
https://pastebin.com/print/i6eSqqyW 2/2