Warning - This site is moving to https://getthecodingbug.anvil.app
Topics covered
​ Code collaboration or working in a team
Building your own coding team
Version control and hub storage
The specification
Start collaborating
On completion
Code collaboration or working in a team
Programmers rarely code in isolation anymore. Except in the case of personal hobby projects, most modern projects have too vast a scope for one person to tackle alone.
In practice, a new project will be broken into several smaller projects and given to several programmers, who may be in the same office or spread out all over the globe.
They will each have a specific task or group of tasks to complete and will share a common hub, where they will store their code and documentation.
Building your own coding team
In this lesson, you will have a core program, which needs to collect information from other modules which will be written by your colleagues.
The main program, 'listCountries.py', will import 'countries.py', which is merely a list of country names, and six other modules, named 'student1.py' through to 'student6.py',
You can then decide amongst yourselves, who gets to code each of the 'student' modules.
Version control and hub storage
There are many ways to store code in a central hub, so that teams can share their code and maintain a history of the changes as the code evolves.
GitHub, BitBucket and SourceForge are just a few of the many companies providing this kind of service.
However, if you are in the same office, you can use an internal server or even an USB stick to pass your code around.
The specification
In each of the 'student' scripts below, there will be a specification in the comments above the function.
This describes what each module is supposed to do.
That is, what data must be supplied by the caller (if any) and what data must be returned (if any).
You have to write the code to perform that task, then test it yourself.
Don't forget to add you name after the ' - Written by: ' text at the top of your module.
When you are happy with your code, then pass your 'student' module on to your colleagues to test. with their code.
Start collaborating
Create a new folder, called, say 'TeamProject', and copy the 8 scripts below into your new folder.
Decide who will code each module or modules and get coding.
Here is the code for 'listCountries.py':
# listCountries.py
from student1 import getListOfCountries
from student2 import getCapitalCity
from student3 import getArea
from student4 import getPopulation
from student5 import getCurrency
from student6 import getDialingCode
print('Available countries are:\n' + getListOfCountries())
print('The capital city of Nepal is ' + getCapitalCity('Nepal'))
print('The currency in Cambodia is the ' + getCurrency('cambodia'))
print('The area in square kilometres of Egypt is ' + getArea('Egypt'))
print('The population of The Philippines is ' + getPopulation('Philippines'))
print('The dialing code for Bulgaria is ' + getDialingCode('bulgaria')) #print('The population density of The Philippines is ' +
# getPopulationDensity('Philippines') + ' per square kilometre')
Here is the code for 'countries.py':
# countries.py
countries = ['Angola','Egypt','Bulgaria','Nepal','Cambodia','Philippines']
Here is the code for 'student1.py':
# student1.py - Written by:
from countries import *
# Function getListOfCountries
# - collects all the names from a list varaible named countries
# - returns the list as a string, with each country on a new line
def getListOfCountries():
return 'unknown'
Here is the code for 'student2.py':
# student2.py - Written by:
from countries import *
capitals = ['Luanda','Cairo','Sofia','Kathmandu','Phnom Penh', 'Manila']
# Function getCapitalCity(country)
# - gets passed the name of a country in a string
# - returns the capital city of that country, in a string
# - tip - the capital cities in the above list are in the same order of the countries
def getCapitalCity(country):
return 'unknown'
Here is the code for 'student3.py':
# student3.py - Written by:
from countries import *
areaSqKm = [1246700,1010408,110994,147181,181035,343448]
# Function getArea(country)
# - gets passed the name of a country in a string
# - returns the area in square km of that country, in a string
# - tip - the areas in the above list are in the same order of the countries
def getArea(country):
return 'unknown'
Here is the code for 'student4.py':
# student4.py - Written by:
from countries import *
population = [25789024,97202100,7101859,28982771,16245729,100981437]
# Function getPopulation(country)
# - gets passed the name of a country in a string
# - returns the population of that country, in a string
# - tip - the populations in the above list are in the same order of the countries
def getPopulation(country):
return 'unknown'
Here is the code for 'student5.py':
# student5.py - Written by:
from countries import *
currency = ['Kwanza','Egyptian Pound','Lev','Nepalese Rupee','Riel','Peso']
# Function getCurrency(country)
# - gets passed the name of a country in a string
# - returns the currency of that country, in a string
# - tip - the currencies in the above list are in the same order of the countries
def getCurrency(country):
return 'unknown'
Here is the code for 'student6.py':
# student6.py - Written by:
from countries import *
dialingCode = ['+244','+20','+359','+977','+855','+63']
# Function getDialingCode(country)
# - gets passed the name of a country in a string
# - returns the telephone dialing code of that country, in a string
# - tip - the dialing codes in the above list are in the same order of the countries
def getDialingCode(country):
return 'unknown'
On completion
When you have all six student modules working and providing the answers - check with Wikipedia.
You can add more questions to 'listCountries.py' to check that your colleagues are not just fudging the answers.
In 'listCountries.py', the last two lines are commented-out. See if you can write a function, in the same module, to provide the answer to population density, then un-comment these two lines to check it out.