You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jarlin Almanzar edited this page Nov 22, 2019
·
3 revisions
Functions
defgreet_user():
"""Display a simple greeting"""print("Hello!")
greet_user()
Passing multiple values
defgreet_user(*names):
"""Display a simple greeting with names"""print(*names)
greet_user('Jarlin', 'Billy')
Passing values within a dict
defgreet_user(name, age, **user_info):
"""Create and display a dict"""user_info['user_name'] =nameuser_info['user_age'] =ageprint(user_info)
greet_user('Jarlin', 'Billy')
Modules
A module is a file ending in .py that contains the code you want to import into your program.
An import statement tells python to make the code in a module available in the currently running program.
How to import
example: name_of_file.py
importname_of_file# How to usename_of_file.name_of_method()