Reference no: EM13341138
You will be creating different functions! For each assignment, you will create a single function.
Template
# Your code header goes here, as always
# This function takes a single letter and a string,
# and returns the number of times the letter occurs in
# the string. (The function will not work if the first
# argument is not a single letter).
def count(letter, myString):
# This function takes in a single list as input, and
# returns the same list sorted.
def sort(myList):
# This function checks to see whether the argument,
# a string, is or is not a palindrome. It will return
# True for palindromes and false otherwise.
def isPalindrome(myString):
# Main will not be graded for correctness; rather,
# we want to see you test these three functions. This
# is for your own sanity as well--you should go through this
# process with every function you write. Each function should
# get called 3 or 4 times with different input, and you should
# print the return value to make sure it is correct.
#
# Included is an example to get you started.
def main():
print("Counting numbers of a's in aardvark:")
print(count("a", "aardvark"))
# Should print 3
You may write more functions than we give you, but you must create the ones listed below.
letterCount(letter, myString) This function should take a single letter, and then a string. It should return the number of times letter occurs in myString. So the call letterCount('h', 'hello') should return 1, and the call letterCount('a', 'aardvark') should return 3. Do not use any of the built in python string functions.
sortList(myList) This function should take myList and return myList sorted. If you are struggling with this, use your code from part 4 of the last homework. If you already have code that puts a number into an already sorted list, with an extra loop sorting shouldn't be that hard. So calling sortList([4, 5, 3, 1]) should return [1, 3, 4, 5], and sortList([8, 10, 1, 2]) should return [1, 2, 8, 10].
isPalindrome(myString) Returns True if myString is a palindrome (the same forward as it is backward) and False otherwise. myString will be a single word. For example, isPalindrome("tacocat") should return True, isPalindrome("anna") should return True, and isPalindrome("DanTheMan") should return False.
main() Main should be used by you to test your program. The main you should submit should show 3 to 4 examples of your function working. So for the isPalindrome, you could print out the result of calling isPalindrome on each of the three strings we gave you in the example, along with one or two examples in which your function works. main() does not need to do things in any particular order or format. Simply call each function 3 or 4 times with different input and print the output. We will be looking at it by hand to make sure you tested your programs.
What is a security risk assessment
: What is a Security Risk Assessment?
|
Spam is email still a useful information service
: Given all the problems with spam is email still a useful information service? Research other networked services available on Linux servers and compare them with email. (500 words)
|
Use a triangle to indicate the challenges and bus processes
: Use a triangle to indicate the challenges and bus processes changes
|
Necessarily memorize to the best of the machine abilities
: If a researcher uses computer models for studying the memorization capabilities of the human mind, do the programs developed for the machine necessarily memorize to the best of the machine's abilities? Explain.
|
The built in python string functions
: letterCount(letter, myString) This function should take a single letter, and then a string. It should return the number of times letter occurs in myString. So the call letterCount('h', 'hello') should return 1, and the call letterCount('a', 'aa..
|
Use an open-addressed hashing table of size m
: 1)Suppose that we use an open-addressed hashing table of size m to store n ? m / 2 items. Assuming uniform hashing, show that for i = 1, 2, ..., n, the probability is at most 2?k that the i-th insertion requires strictly more than k probes.
|
Provide analysis on the difference between batch
: Provide analysis on the difference between batch, visual basic, and powershell scripts then analyze when you would use each scripts and for what purpose. I.E. Batch for reception, powershell and VBScript for Administioration.
|
How long is your commute to work
: Survey Questions - When writing survey questions it is very important to be careful how you word your questions. For example, if someone is asked, "How long is your commute to work," you might get answers that say how long it takes someone to ..
|
Staples
: Staples
|