Exercises
In the same my_variables.py
file which you got open
Create a variable
long_hair
. If your hair is long set it toTrue
, otherwise set it toFalse
. And remember, if you bought your hair it's yours! Don't let anyone tell you different.Create a variable called
goat_music
and that holds your favourite song. Using either string concatenation or the format function, print a message saying that the song ingoat_music
is the greatest song of all time. E.g. ifgoat_music = "Yellow by Coldplay"
then print "Yellow by Coldplay is the Greatest Song of All Time".Let's start with two variables:
wheels_on_bike = 2
andwheels_on_car = 4
. Create a variable calledtotal_wheels
that contains the sum of the two previous variables.Create 3 variables
mysterious_question
,simulation
andthe_answer_to_everything
.the_answer_to_everything
should be equal tomysterious_question
+simulation
. Givemysterious_question
andsimulation
2 numerical values that would makethe_answer_to_everything
equal to 42. Printthe_answer_to_everything
to confirm.Create 3 variables for a triangle:
side1
,side2
andside3
. Assign them values of 3, 4 and 5 respectively. What is the perimeter of this triangle? This triangle is a right triangle, withside1
andside2
as the base and height. Can you create a variable and store its area?
Last updated