Open main menu

CDOT Wiki β

Changes

OPS435 Python3 Lab 6

39 bytes removed, 21:55, 3 November 2019
LAB REVIEW
* Programmer-defined types
* Class Object
* Class methodsfunctions: __init__, __str__, etc* Class instance: attributes and methods
* Object instantiation
* Object Attributes: data attributes and methods
* Pure Function
* Scopes and Namespaces: local, nonlocal, and global
* Class definition syntax
* Class and Instance variables
* Iterators and Generators
 
* Operator overloading
= INVESTIGATION 1: Creating Classes =
:#Use the following as a template(warning this is NOT the same as student.py):<source lang="python">
#!/usr/bin/env python3
# Author ID: [seneca_id]
class Student:
# What is self used for in an object?
# What does it mean to instantiate an object?
# Import the Student class into ipython3python3, instantiate some objects, and try changing different attributes, and adding new attributes.
# Make a copy of lab6a.py called lab6practice.py, make the Student class accept another argument called program. When you create the new object: student = Student('name', '123456789', 'CTY'). Can you print the new students program out with student.program?
# Create a new method in lab6practice.py that checks to make sure the program is either "CTY" or "CNS", if it's not one of these, change the value to "unknown". Make sure the attribute is changed after your object is created.
1,760
edits