ubuntu2004
Kernel: Python 3 (system-wide)
Exercise 5.1
Assign the string "The Beagle" to a string variable called
darwin_ship
.Print
darwin_ship
.Print the length of
darwin_ship
.
In [0]:
Exercise 5.2
Assign the empty string to the variable
famous_scientists
.Add "Jane" to your empty string.
Add a space to your string.
Add "Goodall" to your string and print it.
In [1]:
Out[1]:
Jane Goodall
Exercise 5.3
Ask for input of your name.
Ask for input of your age.
Using an f-string print
X is Y years old
where X is your name and Y is your age.
In [0]:
Exercise 5.4
Ask for input of 2 decimal numbers.
Using an f-string print
X / Y = Z
where X and Y are the two numbers and Z is the result of X divided by Y rounded to 1dp.
In [0]:
Exercise 5.5
Assign the numbers 4.5735, 9.4253 and 1.223 to the variables
x
,y
, andz
respectively.Using an f-string print each number rounded to 2dp and separated by a tab.
In [0]: