Check this video : https://www.youtube.com/watch?v=hgI0p1zf31k
The link below exposes a style guide for python, I strongly recommend that you read these guidelines before sending your project. It will be helpful to improve the readability of the code.
https://www.python.org/dev/peps/pep-0008/#introduction
Here are a few short quotes from the guide :
One of Guido’s key insights is that code is read much more often than it is written. As PEP 20 says, “Readability counts”.
A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is the most important.
Limit all lines to a maximum of 79 characters.
Spaces are the preferred indentation method.
Indentation : Use 4 spaces per indentation level, no tabs. Continuation lines should align wrapped elements either vertically using Python’s implicit line joining inside parentheses, brackets and braces, or using a hanging indent
# Correct:
# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Wrong:
# Arguments on first line forbidden when not using vertical alignment.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Acceptable
# No extra indentation.
if (this_is_one_thing and
that_is_another_thing):
do_something()
# Add some extra indentation on the conditional continuation line.
if (this_is_one_thing
and that_is_another_thing):
do_something()
# Wrong:
# operators sit far away from their operands
income = (gross_wages +
taxable_interest +
(dividends - qualified_dividends) -
ira_deduction -
student_loan_interest)
# Correct:
# easy to match operators with operands
income = (gross_wages
+ taxable_interest
+ (dividends - qualified_dividends)
- ira_deduction
- student_loan_interest)
# Correct:
import os
import sys
# Correct:
from subprocess import Popen, PIPE
# Wrong:
import sys, os
# Correct:
spam(ham[1], {eggs: 2})
# Wrong:
spam( ham[ 1 ], { eggs: 2 } )
# Correct:
if x == 4: print x, y; x, y = y, x
# Wrong:
if x == 4 : print x , y ; x , y = y , x
# Correct:
x = 1
y = 2
long_variable = 3
# Wrong:
x = 1
y = 2
long_variable = 3
# Correct:
i = i + 1
submitted += 1
x = x*2 - 1
hypot2 = x*x + y*y
c = (a+b) * (a-b)
# Wrong:
i=i+1
submitted +=1
x = x * 2 - 1
hypot2 = x * x + y * y
c = (a + b) * (a - b)
# Correct:
def complex(real, imag=0.0):
return magic(r=real, i=imag)
# Wrong:
def complex(real, imag = 0.0):
return magic(r = real, i = imag)
# Correct:
if foo == 'blah':
do_blah_thing()
do_one()
do_two()
do_three()
# Wrong:
if foo == 'blah': do_blah_thing()
do_one(); do_two(); do_three()
# Correct:
FILES = [
'setup.cfg',
'tox.ini',
]
initialize(FILES,
error=True,
)
# Wrong:
FILES = ['setup.cfg', 'tox.ini',]
initialize(FILES, error=True,)
"""Return a foobang
Optional plotz says to frobnicate the bizbaz first.
"""
"""Return an ex-parrot."""
Never use the characters ‘l’ (lowercase letter el), ‘O’ (uppercase letter oh), or ‘I’ (uppercase letter eye) as single character variable names.
Function names should be lowercase, with words separated by underscores as necessary to improve readability.
-Variable names follow the same convention as function names.
PATH = '/my/path'
-Use is not operator rather than not … is. While both expressions are functionally identical, the former is more readable and preferred:
# Correct:
if foo is not None:
# Wrong:
if not foo is None:
# Correct:
def f(x): return 2*x
# Wrong:
f = lambda x: 2*x
# Correct:
try:
value = collection[key]
except KeyError:
return key_not_found(key)
else:
return handle_value(value)
# Wrong:
try:
# Too broad!
return handle_value(collection[key])
except KeyError:
# Will also catch KeyError raised by handle_value()
return key_not_found(key)
# Correct:
if not seq:
if seq:
# Wrong:
if len(seq):
if not len(seq):
# Correct:
if greeting:
# Wrong:
if greeting == True:
Rmarkdown allows you to generate html, pdf and even word files. You can easily integrate R as Python and make your analyses in the document in order to communicate your code or their outputs (e.g. automate a report).
Unlike latex and html markdown is very easy to read in its raw state. The layout, titles, tables etc… are very easy to handle and do not hinder readability.
Before going deeper into details, see how to easily create an html or a pdf (or others) with Rmarkdown using R studio:
Check this cheatsheet: https://rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf
The header of a Rmarkdown file is by default structured as follow :
---
title: "My Title"
author: "Name"
date: "10/02/2021"
output: html_document
---
---
title: "My Title"
author: "Name"
date: "10/02/2021"
output:
html_document:
toc: true
number_sections: true
---
---
author: "Name"
abstract: "Abstract"
output:
pdf_document:
toc: true
number_sections: true
---
---
output:
html_document:
theme: flatly
---
To create a title in markdown you need to use a #
each #
represents a title level. ##
returns a level two title.
To create a new paragraph just end a line with two spaces. Otherwise you can skip a line to start a new paragraph but there will be a space between the two paragraphs.
To write in italics or bold you only have to specify one *
or two **
respectively.
Escaped character (remember it from chap 3 ;) ) must be specified with a \ before. \*
give *
To write example of code without running it like this import numpy as np
just use ```import numpy as np```
Show image from your computer in the output 
You can write directly in html, for example add a link to an external webpage : <a href="https://www.google.com/">Google</a>
You can write in \(\LaTeX\): \(\frac{1}{2}\) . You just need to write the equation between two $
To make bulletpoints like this:
knitr::opts_chunk$set(echo = TRUE)
You can set there chunk option for all you document, you can specify if we will see the code, the output, warnings, errors etc etc. Please see all options on the cheatsheet.
As you noted a chunk start with ```{}
. First you specify the language used within the chunk and then the title of the chunk, after the comma, specify options for the given chunk :
```{r chunk1, error = T}
---
between two empty lines or create a new title.rmarkdown::render('C:/Users/Beta/Documents/GitHub/M1_TDP/examples/Markdown/test.Rmd', 'pdf_document')
R -e "rmarkdown::render('C:/Users/Beta/Documents/GitHub/M1_TDP/examples/Markdown/test.Rmd', 'pdf_document')"
import os
os.system('''R -e "rmarkdown::render('C:/Users/Beta/Documents/GitHub/M1_TDP/examples/Markdown/test.Rmd', 'pdf_document')" ''')
Github is a company that creates products that use the open source tool git. From wikipedia: “Git is a distributed version-control system for tracking changes in any set of files, originally designed for coordinating work among programmers cooperating on source code during software development.”.
A repository is usually used to organize a single project. Repositories can contain folders and files, images, videos, spreadsheets, and data sets etc, etc.
Now that the directory is created, collaborators can work on it and contribute to the project. The final version of the project can be found on the ‘main’ branch.
You can create a branch in order to start editing the project and save your changes on your own branch. Often branches will be linked to specific aspects of the project and will then be removed once the changes have been integrated into the final version.
Keeping your folder update
If you are working on different aspects of your project you probably want to integrate into your computer folder the changes made by your collaborators, so you should regularly check if any changes have been made to a given branch and pull origin if necessary. Make sure you check the changes made to the files before doing it!
Clone this repository and follow the instructions: https://github.com/master-ds2e/exam-schedules