COMPSCI 105 Study Guide - Midterm Guide: Codex Corbeiensis Ii, Json, Bort

426 views4 pages

Document Summary

Deep copy recursively copies the objects referred to. Need to import classes from file e. g. from fraction import fraction. Expression for variable in sequence if condition my_list = [x for x in range(0,10) if x % 2 == 0] >>> my_list = [c for c in name if c not in vowels] class name_of_the_class: #numerator (private functions cannot be accessed outside of class) def __repr__(self): return "fraction({0}, {1})". format(self. __num, self. __den) def __str__(self): return str(self. __num) + "/" + str(self. __den) Set method def setnumerator(self, top): self. __num = top. Expression f1 + f2 f1 - f2 f1 == f2. __eq__(f2) def __add__(self, other): def __eq__(self, other): if not isinstance(other, fraction): return false. Common arithmetic operators object. __add__(self, other) = + object. __sub__(self, other) = - object. __mul__(self, other) = * object. __truediv__(self, other) = / Common relational operators object. __lt__(self, other) = < object. __le__(self, other) = <= object. __eq__(self, other) = == object. __ne__(self, other) = != object. __gt__(self, other) = > object. __ge__(self, other) = >=

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

Related Documents