MCPcopy Create free account

hub / github.com/AlessandroCorradini/MIT-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python / functions

Functions64 in github.com/AlessandroCorradini/MIT-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python

↓ 4 callersMethodapply_shift
Applies the Caesar Cipher to self.message_text with the input shift. Creates a new string that is self.message_text shifted down the
Problem Set 5/Problem 1 - Build the Shift Dictionary and Apply Shift.py:100
↓ 4 callersMethodbuild_shift_dict
Creates a dictionary that can be used to apply a cipher to a letter. The dictionary maps every uppercase and lowercase letter to a
Problem Set 5/Problem 1 - Build the Shift Dictionary and Apply Shift.py:72
↓ 4 callersFunctionplayHand
Allows the user to play the given hand, as follows: * The hand is displayed. * The user may input a word or a single period (the string
Problem Set 4/Problem 5 - Playing a Hand.py:13
↓ 3 callersFunctiongetGuessedWord
secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: string, comprised
Problem Set 3/Problem 2 - Printing Out the User's Guess.py:26
↓ 2 callersFunctioncalculate
(month, balance, minPay, monthlyInterestRate)
Problem Set 2/Problem 2 - Paying Debt off in a Year.py:35
↓ 2 callersFunctioncalculateHandlen
Returns the length (number of letters) in the current hand. hand: dictionary (string int) returns: integer
Problem Set 4/Problem 4 - Hand Length.py:6
↓ 2 callersFunctiongetWordScore
Returns the score for a word. Assumes the word is a valid word. The score for a word is the sum of the points for letters in the word, m
Problem Set 4/Problem 1 - Word Scores.py:22
↓ 1 callersFunctionSquareHelper
(n, x)
Midterm Exam/Problem 3.py:25
↓ 1 callersFunctioncalculate
(month, balance, minPay, monthlyInterestRate)
Problem Set 2/Problem 3 - Using Bisection Search to Make the Program Faster.py:56
↓ 1 callersMethodcount
assumes e is hashable Returns the number of times e occurs in self.
Final Exam/Problem 6.py:77
↓ 1 callersMethoddecrypt_message
Decrypt self.message_text by trying every possible shift value and find the "best" one. We will define "best" as the shift that
Problem Set 5/Problem 3 - CiphertextMessage.py:44
↓ 1 callersFunctiong
(m)
Final Exam/Problem 2.py:20
↓ 1 callersFunctiongetAvailableLetters
lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters that represents what letters have not
Problem Set 3/Problem 3 - Printing Out all Available Letters.py:21
↓ 1 callersFunctionisValidWord
Returns True if word is in the wordList and is entirely composed of letters in the hand. Otherwise, returns False. Does not mutate hand
Problem Set 4/Problem 3 - Valid Words.py:18
↓ 1 callersFunctionisWordGuessed
secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: boolean, True if a
Problem Set 3/Problem 1 - Is the Word Guessed.py:16
↓ 1 callersFunctionmax_val
t, tuple Each element of t is either an int, a tuple, or a list No tuple or list is empty Returns the maximum int in t or (r
Final Exam/Problem 4.py:17
↓ 1 callersMethodremove
assumes e is hashable If e occurs in self, reduces the number of times it occurs in self by 1. Otherwise does nothing.
Final Exam/Problem 6.py:69
↓ 1 callersFunctionupdateHand
Assumes that 'hand' has all the letters in word. In other words, this assumes that however many times a letter appears in 'word', 'hand'
Problem Set 4/Problem 2 - Dealing with Hands.py:59
FunctionSquare
(x)
Midterm Exam/Problem 3.py:22
Method__add__
(self, bag)
Final Exam/Problem 6.py:125
Method__init__
Initializes a Message object text (string): the message's text a Message object has two attributes:
Problem Set 5/Problem 1 - Build the Shift Dictionary and Apply Shift.py:42
Method__init__
Initializes a PlaintextMessage object text (string): the message's text shift (integer): the shift associate
Problem Set 5/Problem 2 - PlaintextMessage.py:21
Method__init__
Initializes a CiphertextMessage object text (string): the message's text a CiphertextMessage object has two
Problem Set 5/Problem 3 - CiphertextMessage.py:32
Method__init__
Assumes center_loc and tent_loc are Location objects Initializes a new Campus centered at location center_loc with a tent at locati
Final Exam/Problem 7.py:71
Methodadd_tent
Assumes new_tent_loc is a Location Adds new_tent_loc to the campus only if the tent is at least 0.5 distance away from all other ten
Final Exam/Problem 7.py:79
Functionbaz
(n)
Problem Set 6/Problem 4.py:41
Methodchange_shift
Changes self.shift of the PlaintextMessage and updates other attributes determined by shift (ie. self.encrypting_dict and m
Problem Set 5/Problem 2 - PlaintextMessage.py:71
Functioncipher
map_from, map_to: strings where each contain N unique lowercase letters. code: string (assume it only contains le
Final Exam/Problem 5.py:21
Functiondecrypt_story
()
Problem Set 5/Problem 4 - Decrypt a Story.py:13
Functiondict_invert
d: dict Returns an inverted dictionary according to the instructions above
Midterm Exam/Problem 7.py:22
Functionf
(x)
Midterm Exam/Problem 2.py:34
Functionf
(x)
Midterm Exam/Problem 1.py:7
Functionf
(n)
Final Exam/Problem 2.py:19
Functionfoo
(n)
Problem Set 6/Problem 4.py:24
Methodfoo
(self)
Final Exam/Problem 2.py:4
Methodfoo
(self)
Final Exam/Problem 2.py:7
Functionfoo_one
Assume n is an int >= 0
Final Exam/Problem 2.py:34
Functionfoo_two
Assume n is an int >= 0
Final Exam/Problem 2.py:42
Functiongeneral_poly
L, a list of numbers (n0, n1, n2, ... nk) Returns a function, which when applied to a value x, returns the value n0 * x^k + n1 * x^(k-1) + .
Midterm Exam/Problem 8.py:9
Methodget_encrypting_dict
Used to safely access a copy self.encrypting_dict outside of the class Returns: a COPY of self.encrypting_dict
Problem Set 5/Problem 2 - PlaintextMessage.py:52
Methodget_message_text
Used to safely access self.message_text outside of the class Returns: self.message_text
Problem Set 5/Problem 1 - Build the Shift Dictionary and Apply Shift.py:55
Methodget_message_text_encrypted
Used to safely access self.message_text_encrypted outside of the class Returns: self.message_text_encrypted
Problem Set 5/Problem 2 - PlaintextMessage.py:62
Methodget_shift
Used to safely access self.shift outside of the class Returns: self.shift
Problem Set 5/Problem 2 - PlaintextMessage.py:43
Methodget_tents
Returns a list of all tents on the campus. The list should contain the string representation of the Location of a tent. The list should
Final Exam/Problem 7.py:107
Methodget_valid_words
Used to safely access a copy of self.valid_words outside of the class Returns: a COPY of self.valid_words
Problem Set 5/Problem 1 - Build the Shift Dictionary and Apply Shift.py:64
Functionhangman
secretWord: string, the secret word to guess. Starts up an interactive game of Hangman. * At the start of the game, let the user know how
Problem Set 3/Problem 4 - The Game.py:35
Methodis_in
assumes e is hashable returns True if e has been inserted in self and not subsequently removed, and False otherwise.
Final Exam/Problem 6.py:201
Functionis_list_permutation
L1 and L2: lists containing integers and strings Returns False if L1 and L2 are not permutations of each other. If they are perm
Midterm Exam/Problem 9.py:35
Functionis_triangular
k, a positive integer returns True if k is triangular and False if not
Midterm Exam/Problem 4.py:18
Functionlargest_odd_times
Assumes L is a non-empty list of ints Returns the largest element of L that occurs an odd number of times in L. If no such element e
Midterm Exam/Problem 6.py:15
FunctionmodSwapSort
L is a list on integers
Problem Set 6/Problem 6.py:31
Functionmodten
(n)
Problem Set 6/Problem 4.py:3
Functionmultlist
m is the multiplication factor n is a list.
Problem Set 6/Problem 4.py:10
Functionnewsearch
(L, e)
Problem Set 6/Problem 5.py:13
FunctionplayGame
Allow the user to play an arbitrary number of hands. 1) Asks the user to input 'n' or 'r' or 'e'. * If the user inputs 'n', let the u
Problem Set 4/Problem 6 - Playing a Game.py:13
FunctionplayGame
Allow the user to play an arbitrary number of hands. 1) Asks the user to input 'n' or 'r' or 'e'. * If the user inputs 'e', immedia
Problem Set 4/Problem 7 - You and your Computer.py:8
Functionprint_without_vowels
s: the string to convert Finds a version of s without vowels and whose characters appear in the same order they appear in s. Prints this ver
Midterm Exam/Problem 5.py:20
Functionrecur
(n)
Problem Set 6/Problem 4.py:31
Methodremove
assumes e is hashable If e occurs one or more times in self, reduces the number of times it occurs in self by 1. Otherwise d
Final Exam/Problem 6.py:192
Methodremove_tent
Assumes tent_loc is a Location Removes tent_loc from the campus. Raises a ValueError if there is not a tent at tent_loc. Doe
Final Exam/Problem 7.py:96
Functionsearch
(L, e)
Problem Set 6/Problem 5.py:4
Functionsum_digits
(string)
Final Exam/Problem 3.py:13
FunctionswapSort
L is a list on integers
Problem Set 6/Problem 6.py:5
Functionto_apply
(x)
Midterm Exam/Problem 8.py:13