#Carmela Dorantes # 19 September, 2021 #What I learned in this lesson was how to use simple funtions with parameters, using arguments, and calling functions. #I did not have issues in this lesson.
#Print statement with arguments seperated by comma print('Hello World!', 'I am sending string arguments to print ')
Hello World! I am sending string arguments to print
# 2 varibale stated, and printed with 4 arguments student_ag e = 17 student_name = "Hiroto Yamaguchi" print(student_name,'will be in the class for',student_age, 'year old students.')
Hiroto Yamaguchi will be in the class for 17 year old students.
#Here is shown that print can be ran with one argument, or empty print("line 1") print("line 2") # line 3 is an empty return - the default when no arguments print() print("line 4")
line 1 line 2 line 4
#12 arguments in one print student_age = 17 student_name = "Hiroto Yamaguchi" high_school = "South Garner" grade="12th" class1= "math" print(student_name,'will be in the class for',student_age, 'year old students.'"He attends",high_school, "high school." ,student_name, "is currenntly in grade", grade, ". His first class is", class1)
Hiroto Yamaguchi will be in the class for 17 year old students.He attends South Garner high school. Hiroto Yamaguchi is currenntly in grade 12th . His first class is Math
# defines a function named say_hi #example function and calling the function def say_hi(): print("Hello there!") print("goodbye") say_hi()
Hello there! goodbye
# define three_three #running function, and then calling the function def three_three(): print(33) three_three()
# Program defines and calls the say_hi & three_three functions # [ ] review and run the code # example of a function being defined, ran, and called def say_hi(): print("Hello there!") print("goodbye") # end of indentation ends the function # define three_three def three_three(): print(33) # calling the functions say_hi() print() three_three()
Hello there! goodbye 33
#Creating, running, and calling a simple fucntion with PHRASE! def yell_it(phrase="hello"): print(phrase.upper()+ "!") yell_it()
# yell_this() yells the string Argument provided #prints it is time to save the notebook def yell_this(phrase): print(phrase.upper() + "!") # call function with a string yell_this("It is time to save the notebook")
IT IS TIME TO SAVE THE NOTEBOOK!
# use a default argument #Prints phrase as a default, and with an argument def say_this(phrase = "Hi"): print(phrase) say_this() say_this("Bye")
#define yell_this, getting user input and displaying message def yell_this(words_to_yell): words_to_yell=input("Enter words to yell here:") print(words_to_yell) yell_this(words_to_yell)