Professional Documents
Culture Documents
Objective:
Throughout this lab you will be able to:
1. Practice some basic python syntax and complete some simple programs;
2. Practice some basic git functions/commands like clone , pull , commit , push .
Git
1. Installation
Install the following software into your machine:
After you have applied the account, make sure you also apply for GitHub Student Developer Pack.
This will be useful.
Then you should clone the repo into your local machine. To clone an image, you simply type the
following in your terminal (mac) /command prompt (Windows).
git clone <your_git_repo>
Your git repo URL may looks like https://www.github.com/peter/comp7940-lab1.git where peter
is your GitHub account name, comp7940-lab1 is your repo's name.
To verify you have done it correctly, you should be able to find a new folder called comp7940-lab1
under your directory. Switch to this directory from your terminal/command prompt by typing:
cd comp7940-lab1
Then, type
git status
$ git status
On branch main
Your branch is up to date with 'origin/main'.
def main():
print("Hello World")
if __name__ == '__main__':
main()
Remember python is very sensitive to indentation. You should use either tab or space for the
indentation but not mixing both of them at the same time.
py -m main
Next we are going to add the file into your Git, type:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: main.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
__pycache__/
5. First Commit
You want to take a "snapshot" of your file system. Do it by
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
__pycache__/
nothing added to commit but untracked files present (use "git add" to track)
6. Push to Github
Type the following to push the content to github
Note: we used to name the default branch as master . In the chaotic 2020, Github decided
to further complicate the world by initiating a renaming process, to rename master to
main as the default branch.
To get familiar with these commands, try to repeat the above steps (Step 4 to 6) several times
while you are writing your python code.
Python Exercise
Try to finish the following tasks by adding one or two lines in the program.
Ex 1
Ex 2
Ex 3
# Write a program that be able to find all factors of the numbers in the list l
l = [52633, 8137, 1024, 999]