variable = 20.0
variable
20.0
variable = 20
variable
20
variable *= 4 # same as variable = variable * 4
variable
80
variable //= 2 # same as variable = variable // 2; "//" to retain the integer type
variable
40
variable += 2 # same as variable = variable + 2
variable
42
variable
42
del variable
variable
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[13], line 1 ----> 1 variable NameError: name 'variable' is not defined
pi = 3.14
answer_to_everything = 42
my_name = "Alexander"
work_address = "WHU, Burgplatz 2, Vallendar"
a = 42
b = a
b
42
a = 87
a
87
b
42
x = [1, 2, 3]
y = x
y
[1, 2, 3]
x[0]
1
x[0] = 99
x
[99, 2, 3]
y
[99, 2, 3]
a
87
42
42
a - 42
45
(a - 42) // 9
5
a = 21 * 2
del a
print("Don't I change the state of the computer's display?")
Don't I change the state of the computer's display?
result = 21 * 2; print("The answer is:", result)
The answer is: 42
result = 21 * 2
print("The answer is:", result)
The answer is: 42
result = 21 * 2
print(
"The answer is:",
result
)
The answer is: 42
for number in [1, 2, 3]:
if number % 2 == 0:
double = 2 * number
print(number, "->", double)
2 -> 4
distance = 891 # in meters
elapsed_time = 93 # in seconds
# Calculate the speed in km/h.
speed = 3.6 * distance / elapsed_time
seconds = 365 * 24 * 60 * 60 # = seconds in the year
seconds_per_year = 365 * 24 * 60 * 60