chrisluiz16

Python Day 1

Jul 17th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. #### int ####
  2.  
  3. ec2-user@DESKTOP-Q259SHJ ~$ python3
  4. Python 3.9.2 (default, Feb 28 2021, 17:03:44)
  5. [GCC 10.2.1 20210110] on linux
  6. Type "help", "copyright", "credits" or "license" for more information.
  7. >>>
  8. >>>
  9. >>> x = 5
  10. >>>
  11. >>> y = 10
  12. >>>
  13. >>>
  14. >>> print(x)
  15. 5
  16. >>>
  17. >>> type(x)
  18. <class 'int'>
  19. >>>
  20. >>> total = x + y
  21. >>>
  22. >>> print(total)
  23. 15
  24. >>>
  25. >>> type(total)
  26. <class 'int'>
  27.  
  28.  
  29.  
  30. #### Float ####
  31.  
  32. >>> x = 5.15
  33. >>>
  34. >>> y = 10.15
  35. >>>
  36. >>> total = x + y
  37. >>>
  38. >>> print(total)
  39. 15.3
  40. >>> type(total)
  41. <class 'float'>
  42.  
  43.  
  44. #### String ###
  45.  
  46. >>> name = "Vysakh"
  47. >>>
  48. >>> x = "@"
  49. >>>
  50. >>> company = "metclouds"
  51. >>>
  52. >>> tld = ".com"
  53. >>>
  54. >>> gmail_id = name + x + company + tld
  55. >>>
  56. >>> print(gmail_id)
  57. Vysakh@metclouds.com
  58. >>>
  59. >>> type(gmail_id)
  60. <class 'str'>
  61.  
  62. >>> x = "5"
  63. >>>
  64. >>> y = "10"
  65. >>>
  66. >>> total = x + y
  67. >>>
  68. >>> print(total)
  69. 510
  70. >>>
  71. >>> type(total)
  72. <class 'str'>
  73.  
  74.  
  75.  
  76. #### Miscellaneous ###
  77.  
  78. >>> name = "Prince"
  79. >>>
  80. >>> total = name * 5
  81. >>>
  82. >>> print(total)
  83. PrincePrincePrincePrincePrince
  84. >>>
  85. >>>
  86. >>> type(total)
  87. <class 'str'>
  88.  
  89.  
  90.  
  91. ### Float Testing ###
  92.  
  93. >>> x = 10.0
  94. >>>
  95. >>> y = 5.0
  96. >>>
  97. >>>
  98. >>> total = x / y
  99. >>>
  100. >>> print(total)
  101. 2.0
  102. >>>
  103. >>> type(total)
  104. <class 'float'>
  105.  
  106.  
  107. #### Difference b/w % and / ####
  108.  
  109. >>> x = 9
  110. >>>
  111. >>> y =6
  112. >>>
  113. >>> total = x % y
  114. >>>
  115. >>> print(total)
  116. 3
  117. >>>
  118. >>>
  119. >>> total = x / y
  120. >>>
  121. >>> print(total)
  122. 1.5
  123.  
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment