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_musicand that holds your favourite song. Using either string concatenation or the format function, print a message saying that the song ingoat_musicis 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 = 2andwheels_on_car = 4. Create a variable calledtotal_wheelsthat contains the sum of the two previous variables.Create 3 variables
mysterious_question,simulationandthe_answer_to_everything.the_answer_to_everythingshould be equal tomysterious_question+simulation. Givemysterious_questionandsimulation2 numerical values that would makethe_answer_to_everythingequal to 42. Printthe_answer_to_everythingto confirm.Create 3 variables for a triangle:
side1,side2andside3. Assign them values of 3, 4 and 5 respectively. What is the perimeter of this triangle? This triangle is a right triangle, withside1andside2as the base and height. Can you create a variable and store its area?
Last updated