Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 10 # int() -> integer
- y = 22.6 # float() -> float
- z = 'Hello World' # str() -> string
- print(x)
- # my_pokemon which contains a string and then print it
- my_pokemon = 'Pikachu'
- print(my_pokemon)
- # casting -> changing a variable type from one type to another type
- a = int(y)
- b = float(x)
- print(a)
- # to know the type of a variable type(variable_name)
- print(type(b))
- print(b)
- c = str(y)
- print(type(c))
- print(c)
- # + (addition)
- # - (subtraction)
- # / (division)
- # // (division to an integer)
- # * (multiplication)
- # ** (power of)
- # % (gives you the remainder of an euclidian division) modulo
- a = 21 % 2
- print(a)
- # concatenation -> adding two strings together
- hello = 'Hello'
- world = 'World'
- print(hello + ' ' + world)
- # declare the level of your pokemon as an integer
- # change it to a string
- # and print the following (with the name and level of your pokemon)
- # Pikachu lvl: 24
- pokemon_lvl = 24
- pokemon_lvl = str(pokemon_lvl)
- print(my_pokemon + ' lvl: ' + pokemon_lvl)
- a = 1
- a += 1 # a = a + 1
- # -= *= etc...
- # declare variable with pokemon health and inflict damage to your pokemon and display (print) the health before and after damage taken.
- pokemon_health = 200
- damage = 55
- print(my_pokemon + ' lvl: ' + pokemon_lvl + ' health: ' + str(pokemon_health))
- pokemon_health -= damage
- print('dealing ' + str(damage) + ' damage to ' + my_pokemon)
- print(my_pokemon + ' lvl: ' + pokemon_lvl + ' health: ' + str(pokemon_health))
Advertisement
Add Comment
Please, Sign In to add comment