Python is not an Object-Oriented language. It's a scripting language with class capabilities.
from datetime import date
today = date(2019, 9, 26)
# 'date' is its own type
print(type(today))
# Attributes of 'today'
print(today.year)
print(today.month)
print(today.day)
# Methods of 'today'
print(today.weekday())
print(today.ctime())
obj.py
animals = ["dog", "cat", "chicken"]
animals.append("sheep") # Modifies the list 'animals'
greeting = "hi there!"
print(greeting.capitalize()) # Returns a new string
class Student:
def __init__(self, zid, name):
self.zid = zid
self.name = name
self.year = 1
def advance_year(self):
self.year += 1
def email_address(self):
return self.zid + "@unsw.edu.au"
rob = Student("z3254687", "Robert Leonard Clifton-Everest")
hayden = Student("z3418003", "Hayden Smith")
student.py
Activity: Use the data in https://www.cse.unsw.edu.au/~cs1531/20T3/weatherAUS.csv to write a python program to determine the location with the most rain over the last years