ubuntu2004
Task 1.1
Using Python code, convert 50 inches into centimetres and print the result using an f-string so the output reads:
where X is your answer.
Hint: If you can't remember how many centimetres in an inch, google it.
Task 1.2
Using Python code, convert 50 inches into feet and inches and print the result using an f-string so the output reads:
where X and Y are your answers.
Hint: Use integer divison and remainder.
Task 1.3
How do you think you could use Python code to indicate if an integer number is odd or even?
Hint: Think what makes an integer odd or even. Then think which arithmetic operator could be used to give you one answer for even and another answer for odd.
Use Python code to test if zero odd or even?
(We will use this code later when calculating the median of a set of data.)
Task 1.5
Which of these variable names should not be used and why?
test
Len
surname
ph
0_value
lambda
alpha
O
cell_concentration
dna_seq
Variable name | valid | reason |
---|---|---|
test | yes | |
Len | no | similar to len() |
surname | yes | |
ph | yes | short, but maybe okay |
0_value | no | starts with a number |
lambda | no | Python reserved word |
alpha | yes | |
O | no | too similar to zero |
cell_concentration | yes | |
dna_seq | yes |
Task 1.6
Bacterial cells replicate by binary division. Under conditions of ample resources, the number of bacteria in a population grows exponentially.
If we wish to predict the size of a population of bacteria after a given time from a starting population we can use the formula
where Nt is the population size after time t, N0 is the starting population size at time t = 0, and d is the average time it takes between bacteria replications; also known as the doubling time.
The units of t and d must be the same (e.g. hours or minutes).
Let the starting population be 450 bacteria and the doubling time be 20 minutes. How many bacteria are there after 12 hours? Your calculation should be performed entirely with Python code.
Task 1.8
When the wind blows in cold weather, the air feels colder than it actually is because the movement of the air increases the rate of cooling for warm objects, like people. This effect is known as wind chill.
This is the formula for calculating wind chill (the temperature it feels like)
where T is the air temperature in degrees Celsius and V is the wind speed in kilometres per hour.
Write some code to calculate wind chill using the variables T
and V
below. Round your answer to 1dp.