You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

new 1.py 409B

5 years ago
5 years ago
1234567891011121314
  1. x = 3
  2. print(type(x)) # Prints "<class 'int'>"
  3. print(x) # Prints "3"
  4. print(x + 1) # Addition; prints "4"
  5. print(x - 1) # Subtraction; prints "2"
  6. print(x * 2) # Multiplication; prints "6"
  7. print(x ** 2) # Exponentiation; prints "9"
  8. x += 1
  9. print(x) # Prints "4"
  10. x *= 2
  11. print(x) # Prints "8"
  12. y = 2.5
  13. print(type(y)) # Prints "<class 'float'>"
  14. print(y, y + 1, y * 2, y ** 2) # Prints "2.5 3.5 5.0 6.25"