Hands On Exercise
Congratulations on completing the lesson on Python variables. Test your knowledge through these short snippets and get one step closer to mastering Python!
Exercise 1
Suppose we want to create a variable sum
and save in it the result of adding the variables num_one
and num_two
. The variables num_one
and num_two
have values of 15 and 25, respectively.
Complete the code and run it to see the output!
num_one = 15______ = 25sum = ____ + ____print(sum)
Exercise 2
Let’s say we want to save a number in the num_three
variable. This number is saved as a string in string_three
. Complete the following code by changing the type of string_three.
string_three = "25"num_three = ____(string_three)print(num_three)
Exercise 3
What will the value of my_var
be at Line 8 of the code?
global my_varmy_var = 10def my_function():my_var = 20my_function()
Enter the input below