Here i will show you what are the python conventions.
First of all, in python the indentation does matter. Indentantion is the way that python recognize if a code block has ended. For example:
if (a < b):
counter + =1
print (counter)
This is wrong because the IF has nothing inside it, instead it will always add 1+ to the counter because is at the same level as the IF. This is not C++ or JS where you can tell the program when your if ends with {}. The right way to do it is this:
if ( a < b):
     counter += 1
print(counter)
Also here are some tips to give a standar python style to your code:
-Just do one statement per line
Please don´t do this:
 
def ejercicio3(diccionario): return ((“Homework promedio:”, sum(diccionario[“homework”])/len(diccionario[“homework” ])), (“Quizzes promedio:”, sum(diccionario[“quizzes”])/len(diccionario[“quizzes”])), (“Tests promedio:”, sum(diccionario[“tests”])/len(diccionario[“tests”])))
Yes, this is a python program that actually works. As you can see it is very hard to read and you will make others to have a bad time trying to understand what you want to do. Don´t be a smart a** and put order to your code so that everyone can understand it. 
-Keep spaces between variables if necessary, just to make it more readable
-Build your functions on the top part of the code
I think that this is clear, declare your functions first and call them below. Try to declare all the functions you can on the top part and write the main program after that, this will make your code easier to read because if someone wants to follow the executuion order of your code he/she doesn´t have to look for a specific function on all the code; otherwise, he/she will know where the functions are and you will save him/her time.
Keep your code simple
Here is an example of the last point:
a = input(“Write a number”))
a = int(a)
for i in range(0,50)
     if i/a % 0:
          counter = counter + 1
b = counter*2
c = b+18
print (c)
This code is really simple but it can be done in less words and space, the proper way to do it is:
a =  int (input(“Write a number” ))
for i in range( 0 , 50 )
     if (i/a) % 0:
          counter += 1
print(counter*2+18)

 

CC BY 4.0 Mastery 8 – Python conventions by Jose Carlos Peñuelas Armenta is licensed under a Creative Commons Attribution 4.0 International License.