Code together and share your code

What is Git

A version control system is a tool that keeps track of these changes for us and helps us version and merge our files. It allows you to decide which changes make up the next version, called a commit, and keeps useful metadata about them. The complete history of commits for a particular project and their metadata make up a repository. Repositories can be kept in sync across different computers facilitating collaboration among different people.

Git is a VCS (version control system).

With git we can avoid the naming mess above, and keep our files named properly, git will take care of the rest.

How to share your code on Github

Open your shell/bash and create a new folder called my_first_git_project move into that folder and the type:

git config --global user.name "YourName"
git config --global user.email "EmailYouUsedForGithub"
git init

With the first 2 commands we just set name and email for git.

The last command initialized a local repository, now you can find a .git inside your folder.

Now let's create a new file called app.py, it can be empty, and then:

git status

Do you see your file? Git sees that you added a new file.

git add app.py
git commit -m 'my first commit'

With the add command we are telling to git we want save this file and with the last command we actually save the file. Until you commit sommething your changes are not stored by git.

Let's create a new remote repository on Github.

git remote add origin YourRepo
git push origin master

Probably git will ask for your email and password, after this if you go on github you should see you repository updated.

Time to show the PRs process!

Code review

Code review is systematic examination (sometimes referred to as peer review) of computer source code.

It is intended to find mistakes overlooked in software development, improving the overall quality of software.

Demo time!

Pair programming

We are going to form groups of 2 people and 1 computer.

One of them will have the control over the computer (driver), the other one (navigator) will check, advice, propose.

One, the driver, writes code while the other, the navigator, reviews each line of code as it is typed in.

The two programmers switch roles frequently (let's say 10 mins).

Challenges: take around 5 to resolve each of the following challenges

In [5]:
# Challenge n. 1
# Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
# between 2000 and 3200 (both included).

In [2]:
# Challenge n. 2
# Given tag and word strings, create the HTML string with tags around the word, e.g. "<i>Yay</i>".
# Example: make_tags('i', 'Hello') → '<i>Hello</i>'

In [3]:
# Challenge n. 3
# Given a string, return the string made of its first two chars, so the String "Hello" yields "He".
# If the string is shorter than length 2, return whatever there is, so "X" yields "X", 
# and the empty string "" yields the empty string "".
# Example: first_two('abcdefg') → 'ab'