<jupyter_start><jupyter_text>Excellent Tutorials Series (ETS) Author: <NAME> Topic: Overview   Simple Functions **`A function`:** A functions a group of statements that exist within a program for the purpose of performing a specific task.- Benefits of using Functions - Simpler code - code reuse - Better Testing - Faster Development  Defining and Calling Function<jupyter_code>def message():
    print(' My name is Thomas')
#Call it
message()<jupyter_output>My name is Thomas<jupyter_text>- Functions have two parts   - `main function:` :calls other function   - `other functions`- Python makes use of a top-down approach to solving problems.- `Local Variables:` It is created inside a function and cannot be accessed by statements outside<jupyter_code>def main():
#     print('I have a message for you')
    message()
    win_team()
    loss_team()
        
def message():
    print('This is Python program for practice')
def win_team():
    print('NPP won')
def loss_team():
    print('JM has lost')
    
main()
message()
#Write a function that displays your name
def main():
    get_name()
#     print()
    
    
    
def get_name():
    name =input('Enter your name: ')
    print('Hello {}'.format(name))
main()
#Write a program to demonstrates two functions have the same
#local variables with same name
def main():
    texas()
    california()
    
    
def texas():
    birds =500
    print('Texas has {}'.format(birds))


def california():
    birds =700
    print('California has {}'.format(birds))
main()
california()<jupyter_output>California has 700<jupyter_text>Passing Arguments Through Functions<jupyter_code>#A program that displays the double of the value
def main():
    double_value(10)
       
def double_value(value):
    ans =value*2
    print('The double value is {:d}'.format(ans))
main()
double_value(40)
double_value(90)
#write function to show the sum of two numbers displayed

value =10
double_value(value)
#Write a function to display the amount of simple interest
#write a program that asks the user to enter distance in kilometers and then converts that distance to miles
# The conversion formula is miles =kilometers *0.6214
# def main():
#     distance()
#     convert()

def distance():
    question =float(input('Distance in km'))
    return question
#     print(question)
# distance()
def convert():
    question =distance()
    con =question*0.6214
    print('Distance in miles{:.3f}'.format(con))
# convert()
distance()
convert()
## write a program that calculates and displays a person's body mass index (BMI). 
#The formula is BMI=weight*703/(heights)^2
#where weight is measured in pounds and height is measured 
def bmi(w,h):
    b =w*703/(h**2)
    print('Your body mass index is {:.2f}'.format(b))
bmi(130, 5.9)
bmi(150, 5.1)<jupyter_output>Your body mass index is 4054.21<jupyter_text>Value Returning Functions and Modules - `Value Returning Functions`: Returns the value of the functions after call is made- `Modules`: They are collection of functions<jupyter_code>import random
ran_no =random.randint(0,10)
ran_no
random.seed(1234)
n=10
arr=[]
for i in range(n):
    arr_i= random.randint(0,10)
    arr.append(arr_i)
print(arr)   
%timeit
def retail_price(sales, dis):
    """
    This program calculates the retail price of sales
    """
    retail =[]
    n =len(sales)
    p_ded =1-dis
    for i in range(n):
        retail.append(p_ded*sales[i])
        print('The retail price is: {:.2f}'.format(retail[i]))
    return retail
r=retail_price([22.34, 34.56, 67.89, 95.67], 0.05)
## write  a program that ask the user to enter the ages of herself and her best and calculate
## the sum of their ages and average of their ages. 
### write two functions that calculates the area and perimeter of rectangle<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10890827385672747, 'fraction_numerical': 0.022997620935765267, 'mean_word_length': 4.0252324037184595, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '151428', 'license': 'MIT', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1136, 'n_words': 440, 'path': 'Lesson3.ipynb', 'repo_name': 'ttorku/py_data_science', 'size': '3791'}