CSCI 1012
sum_check.pyfibonacci.pytwo_dice.py.zip with all the .py files
| Operator | Function (with numbers) |
|---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
** |
Exponentiation |
// |
Quotient |
% |
Remainder |
Does this work?
A, B, and C will be intsTrue if any two args sum to the third
FalseExamples:
sum_check(1, 3, 4) returns Truesum_check(2, 3, 4) returns Falsesum_check(0, 0, 0) returns True| Operator | Function | Syntax |
|---|---|---|
== |
Equal? | 3 == 5 |
!= |
Not equal? | 3 != 5 |
< |
Less than? | 3 < 5 |
> |
Greater than? | 3 > 5 |
<= |
Less than or equal to | 3 <= 5 |
>= |
Greater than or equal to? | 3 >= 5 |
if
elif (“else if”)
else
while loop
iffor loop
range functionn
Examples:
fibonacci(12) returns string '1 1 2 3 5 8'fibonacci(30) returns string '1 1 2 3 5 8 13 21'Return how many ways there are to get the sum of two 6-sided dice to add to the argument.
Examples:
two_dice(1) returns 0two_dice(2) returns 1 (1+1)two_dice(3) returns 2 (1+2, 2+1)two_dice(4) returns 3 (1+3, 3+1, 2+2)❗ Exam on 6 October. (in lecture)
Homework 6 due Sunday, 5 Oct 11:55 PM