American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • 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

  1. Create a function with return value, “convert_miles_to_km”, with 1 parameter: miles.
    1. 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.
    2. Outside the function:
      1. Ask user in the shell “Enter number of miles: “
      2. Get the user input and call the function and pass the user input as the parameter.
      3. 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:   *

Details

Date:
January 2
Time:
7:00 pm - 8:00 pm
Verified by MonsterInsights