Functions Continued, Modules, Packages, Classes
In this chapter you’ll learn to write functions, which are named blocks of code that are designed to do one specific job. When you want to perform a particular task that you’ve defined in a function, you call the name of the function responsible for it. If you need to perform that task multiple times throughout your program, you don’t need to type all the code for the same task again and again; you just call the function dedicated to handling that task, and the call tells Python to run the code inside the function. You’ll find that using functions makes your programs easier to write, read, test, and fix.
Here’s a simple function named greet_user() that prints a greeting:
def greet_user():
"""Display a simple greeting."""
print("Hello!")
greet_user()
The function now expects you to provide a value for username each time you call it. When you call greet_user(), you can pass it a name, such as 'jesse', inside the parentheses:
def greet_user(username):
"""Display a simple greeting."""
print(f"Hello, {username.title()}!")
greet_user('jesse')
-
Copy the url of the repository ending with .git (https://github.com/2019-Fall/week4.git)
-
GitHub Desktop:
- Go to Current Repository
- click on Add drop down
- Clone Repository
- click on URL tab
- paste the copied URL (https://github.com/2019-Fall/week4.git)
- choose the location from your local machine
C:\dev\
then click on Clone.
Git Bash: navigate to the right directory
C:\dev\
and enter following:
git clone https://github.com/2019-Fall/week4.git
- [optional] Create your feature branch:
git checkout -b week4_john
- Open the
C:\dev\week4
folder from your VS Code and start modifying the code.
- clone the repository from asotools
git clone <url>
cd newrepo
git checkout -b 'yourbranch'
- make changes in your repository, local changes.
- Go to your github account create a new repository to save YOUR changes
- Get the URL of that repository from Github
- Set the your branch upstream to your Github repository that you just created.
git push --set-upstream <url from your github repo>
- To get he updates from asotoolsny repo switch to master branch and then git push
git checkout master
git pull
- to get new changes from updated master to your branch:
git rebase master