12. Comments and blank lines

  • It is good practice to layout your code so it can be easily understood by others
  • This includes using comments and blank lines to space oout your code and label it to explain what it does
  • Comment lines are ignored by the interpreter. They are used to write information useful to someone reading the code
  • Look how easy it is to understand!
#get amount of pounds & pence to convert
pounds = float(input("Enter amount to convert: ")

#convert to euros
euros = pounds * 1.2406

#print to two decimal places
print("%.2f" % euros)

#print normally
print(euros)

Tasks

  1. Go through all the examples you have completed so far and add comments and blank lines, where necessary, to make your code easier to read