When writing programs, we often want to name values so that we can refer to them later. A name that refers to a value is called a variable.
x = 10
The general form of a variable assignment statement is:
«variable» = «expression»
An assignment statement is executed as follows:
We can now retrieve the value that x refers to by typing x in the shell:
x
We computed things like 10 + 5 before. Now we can use variables in place of actual numbers:
x + 5
The code x + 5 is an expression, just like 10 and 10 + 5 are, so we can store the result in a variable:
result = x + 5
result
Variable names must start with a letter or an underscore. They can only include letters, digits, and underscores.
Consider this code:
j = 7Write an assignment statement that creates a new variable
k that refers to three times j's value.
Consider this code:
patient_a = 3 patient_b = 4 patient_a = 5After the code above is executed, to which value does
patient_a refer?patient_b refer?
Consider this code:
x = 4 y = x + 2 x = y + 1After the code above is executed, to which value does
x refer?y refer?
Fridericia's Formula for the corrected QT is $$QTc = \frac{QT}{RR^{\frac{1}{3}}}$$
The R-R interval is measured in seconds, and can be ontained using $60/hr$, where hr is the heart rate. Given the hr and qt variables below, and calculate the QTc (corrected QT interval).
hr = 70
qt = 300
The corrected QT interval should be: 315.817979882819 seconds.