Guest User

Untitled

a guest
Mar 21st, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.47 KB | None | 0 0
  1. x = 10  # int() -> integer
  2. y = 22.6  # float() -> float
  3. z = 'Hello World' # str() -> string
  4.  
  5. print(x)
  6.  
  7. # my_pokemon which contains a string and then print it
  8. my_pokemon = 'Pikachu'
  9. print(my_pokemon)
  10.  
  11.  
  12. # casting -> changing a variable type from one type to another type
  13. a = int(y)
  14. b = float(x)
  15. print(a)
  16. # to know the type of a variable type(variable_name)
  17. print(type(b))
  18. print(b)
  19.  
  20. c = str(y)
  21. print(type(c))
  22. print(c)
  23.  
  24. # + (addition)
  25. # - (subtraction)
  26. # / (division)
  27. # // (division to an integer)
  28. # * (multiplication)
  29. # ** (power of)
  30. # % (gives you the remainder of an euclidian division) modulo
  31.  
  32. a = 21 % 2
  33. print(a)
  34.  
  35. # concatenation -> adding two strings together
  36.  
  37. hello = 'Hello'
  38. world = 'World'
  39.  
  40. print(hello + ' ' + world)
  41.  
  42. # declare the level of your pokemon as an integer
  43. # change it to a string
  44. # and print the following (with the name and level of your pokemon)
  45. # Pikachu lvl: 24
  46.  
  47. pokemon_lvl = 24
  48. pokemon_lvl = str(pokemon_lvl)
  49. print(my_pokemon + ' lvl: ' + pokemon_lvl)
  50.  
  51.  
  52. a = 1
  53. a += 1  # a = a + 1
  54. # -= *= etc...
  55.  
  56. # declare variable with pokemon health and inflict damage to your pokemon and display (print) the health before and after damage taken.
  57.  
  58. pokemon_health = 200
  59. damage = 55
  60.  
  61. print(my_pokemon + ' lvl: ' + pokemon_lvl +  ' health: ' + str(pokemon_health))
  62.  
  63. pokemon_health -= damage
  64. print('dealing ' + str(damage) + ' damage to ' + my_pokemon)
  65.  
  66. print(my_pokemon + ' lvl: ' + pokemon_lvl +  ' health: ' + str(pokemon_health))
Advertisement
Add Comment
Please, Sign In to add comment