← All advanced lessons

Advanced Python / A00

Advanced Overview

The complete advanced-course outline, planning notes, topics, and supporting examples.

Advanced Python - Overview

Outline of chapters:

Need to put Tuples in somewhere

Need to put JSON somewhere

Need to put DocString somewhere

Remove slicing from intro, incorporate into advanced

Is there Inheritance in intro? Put that in somewhere….

Expand on assignments for each chapter.

Come up with bigger programming assignments

Quizzes for all Advanced chapters

GUI

Topics:

.join function for strings

Sources:

NOTES FROM BOOK: Python Crash Course

squares = []

for value in range(1,11):

squares.append(value**2)

print(squares)

squares = [value**2 for value in range(1, 11)]

print(squares)

(maybe go back to inheritance?)

NOTES FROM: LEARN PYTHON - FULL COURSE FOR BEGINNERS

Try/except:

try:

number = int(input(“Enter a number:”)

print(number)

except:

print(“Invalid input”)

  • except - Catches any error
  • 10 / 0 is an error - Division by zero

except ZeroDivisionError:

print(“Division by zero”)

except ValueError:

print(“Invalid input”)

except ZeroDivisionError as err:

print(err)

Read from a file:

open(“employees.txt”, “r”) # path to the file, read mode

# w is write mode

# a is to append to end of file

# r+ read and write

employee_file = open….

employee_file.close()

  • print(employee_file.readable()) # make sure file is readable true/false

print(employee_file.read()) # prints entire file

  • print(employe_file.read()) # grabs first line, waits at next line
  • .readlines() # puts each line into an array

for employee in employee_file.readlines():

print(employee) # prints each line

Writing and appending to files:

open(“employees.txt”, “a”) # adds onto file

employee_file.write(“Toby - human resources”)

Modules and pip:

pip –version # make sure you have it

pip install python- docx

import docx # pulls from site packages

Classes and Objects:

class Student:

def __init__(self, name, major, gpa, is_on_probation):

self.name = name

self.major = major

self.gpa = gpa

self.is_on_probation = is_on_probation

from Student import Student # from student file, import student class

student1 = Student(“Jim”, “Business”, 3.1, False)

print(student1.name) # prints name

  • Class functions:

class Student:

def __init__(self, name, major, gpa, is_on_probation):

self.name = name

self.major = major

self.gpa = gpa

self.is_on_probation = is_on_probation

def on_honor_roll(self):

if self.gpa >= 3.5:

return True

else:

return False

print(student1.on_honor_roll())

class Chef:

def make_chicken(self):

print(“The chef makes a chicken”)

def make_salad(self):

print(“The chef makes salad”)

def make_special_dish(self):

print(“The chef makes BBQ ribs”)

from Chef import Chef

myChef = Chef()

myChef.make_chicken()

from Chef import Chef

class ChineseChef(Chef): # use everything that is in the Chef class

def make_fried_rice(self):

print(“The chef makes fried rice”)

def make_special_dish(self): # Overrides the other special

print(“The chef makes orange chicken.”)

NOTES FROM: LEARN PYTHON - FULL COURSE FOR INTERMEDIATE