-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab1.txt
31 lines (30 loc) · 1.84 KB
/
lab1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This part of the lab will introduce you to the basics of python programming. You are not allowed to use any library functions for this lab unless it is specifically stated in the specification
Write the following functions in lab1.py
The function names must be exactly as specified. The number and order of arguments must be the same.
Function 1:
Name: wins_rock_scissors_paper
Parameters: 2 strings
Return: a boolean value
Description: This function is passed two strings. Each of the two strings is going to be one of 3 values:
rock
paper
scissors
The strings may have any casing. Rock, ROCK, roCK are all possible and valid.
The first string represents what the player threw in a game of rocks paper scissors. The second string represents what the opponent threw. This function returns true, if the player won, and false if it was a tie or a loss.
In a game of rock, paper, scissors, each player "throws" one of the 3 items. The winner is determined by the following rules
rock beats scissors
paper beats rock
scissor beats paper
Function 2:
Name: factorial
Parameters: a number (int)
Return: a number (int)
Description: This function is passed a non-negative integer, that we will call n in this description. the function returns n! (pronounced n factorial). n! = n * (n-1) * (n-2)... * 1 Thus, 3! = 3 * 2 * 1. Note that 0! is 1 by definition.
Function 3:
Name: Fibonacci
Parameters: a number (int)
Return: a number (int)
Description: This function is passed a non-negative integer, that we will call n in this description. the function returns the nth Fibonacci number in the Fibonacci sequence.
The nth Fibonacci number is the sum of the 2 previous Fibonacci numbers. Here is a sample of the Fibonacci series
1, 1, 2, 3, 5, 8, 13, 21, ..
This means that your function should return 13 if the parameter sent to it is 6 and 1 if the parameter is 2