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 [2]:
Out[2]:
The Beagle
10
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 [3]:
Out[3]:
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 [8]:
Out[8]:
input of your name
input of your age
Artur is 18 years old
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 [15]:
Out[15]:
0.3
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 [16]:
Out[16]:
4.6 9.4 1.2