- This event has passed.
6:30pm – Intro to Python – Roland
April 23 @ 6:30 pm - 7:30 pm
Today We Did
- Reviewed Function with Return Value HW
- Overloading functions
- Did more review of Functions with Return Values
- Conversion problems
- Searching for items in lists (returns True or False)
- Is item in list?
- Is even number in list?
Homework:
Submit the following file into your Google Drive Homework Folder
- “Apr23_FunctionHW.py” do the following problems below:
- Create a function, “hello_world”, with no parameter and inside the function, it will print “Hello World”. Call the function.
- Create a function, “greeting”, with one parameter, “name”. Inside the function, print to the shell the combination of the word “Greeting ” and the name parameter. Call the function like this “greeting(‘Gamas’)” . The result should be “Greeting Gamas” in the shell.
- Create a function, “combine_words”, with 3 parameters. Inside the function, print the combination of all three parameters. Call the function like this: “combine_words(‘Hello ‘, ‘Mr. ‘, ‘Gamas.’)” . This will print ‘Hello Mr. Gamas’ to the shell.
- 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”.
If you have any questions, feel free to email me at rolandyang@ayclogic.com