CSC148H1 Lecture Notes - Lecture 5: Init, Docstring, Triple Parentheses

56 views4 pages
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

References: all code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter/ Assignment 1 and lab 2 exercises have been posted. The __lt__ method doesn"t work under all conditions: doesn"t work if one number is negative. Write a functional if statement: already know dysfunctional if statement -> code from last lecture that didn"t work. Functional if statement: if else If condition is true, expression 1 is returned. If condition isn"t true, expression 2 is returned: n1 * d2 < n2 * d1 if d1 * d2 > 0 else n1 * d2 > n2* d1. This can be written in python as: Class rational doesn"t exist as a type in the header, so it needs to written as a string. No quotes around rational because it has already been defined. It has been mentioned several times throughout the code that the denominator shouldn"t be 0: known as a precondition .

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents