- This event has passed.
7pm – Intro to Python – Joshua Widjanarko
January 2 @ 7:00 pm - 8:00 pm
Today We Did:
- return function and how to use it
- reviewed how to create funcions
With return,there is a different way to call a function by setting it equal to a variable
Basically, we need to take what the function is returning, and put it somewhere
variable_name= function_name(paramaters)
Homework
#Name your homework functions_return_hw.py
- Create a function with return value, “convert_miles_to_km”, with 1 parameter: miles.
- Inside the function, convert the parameter “miles” into the “km” value. There are 1.6 km in one mile. Return the conversion result or the km value.
- Outside the function:
- Ask user in the shell “Enter number of miles: “
- Get the user input and call the function and pass the user input as the parameter.
- Print “There are {result of the function} kms in {user_input} miles”.
Hints when creating the function, within the () should have no “” marks
Look above for an example to call a function
To convert, you will need to multiply using this symbol: *