1: How to Answer these Questions

Write functions to solve all of the questions. Here are two example questions and their solutions. Notice that the first function prints a value, the second function returns a value.

1 Hello <Name>

Write a function that accepts a name as a parameter and prints out “Hello ” <name>

1.1 Example

 *** Output ***
Hello Kim

2 Average of two numbers

Write a function that accepts two numbers and returns the average of the two numbers.

2.1 Example

 *** Output ***

3 Solutions

1: def hello(s):
2:     print("Hello ",s)
4: def average(i,j):
5:     return (i+j)/2
7: hello("Kim")
8: print(average(3,5))

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.