Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def areElementsInList ( list 1 , list 2 ) : ' ' ' This function takes two lists as its parameters ( list 1 and

def areElementsInList(list1, list2):
''' This function takes two lists as its parameters (list1 and
list2). Return True if each element in list1 exists in list2.
Return False otherwise. If list1 contains no elements, True is
returned.
'''
# COMPLETE FUNCTION DEFINITION HERE
assert areElementsInList(["one",2],[0,"one",2,"three"])== True
assert areElementsInList([],[1,2,3,4])== True
assert areElementsInList([1,2,3],[1,2])== False
assert areElementsInList([1,2,3],[3,2,1])== True
def alternateCase(s):
''' This function takes a string parameter (s) and returns a new
string that flips the case of each alpha character in s.
'''
# COMPLETE FUNCTION DEFINITION HERE
assert alternateCase("")==""
assert alternateCase("This is a Sentence")== "tHIS IS A sENTENCE"
assert alternateCase("CS9")=="cs9"
assert alternateCase("9.95")=="9.95"
def getCharacterCount(s):
''' This function takes a string parameter (s) and returns a dictionary
type where each key in the dictionary is a unique upper-case character
in s and its associated value is the number of occurences the unique
character exists in s. Note that the unique characters should be case
insensitive ("a" and "A" are considered the same and should be stored as
"A" in the dictionary). Non alpha characters (including whitespaces)
and their occurences should also be stored in the dictionary.
'''
# COMPLETE FUNCTION DEFINITION HERE
x = getCharacterCount("This is a Sentence")
assert x.get("S")==3
assert x.get("P")== None
assert x.get("I")==2
assert x.get("")==3
y = getCharacterCount("Pi is Approximately 3.14159")
assert y.get("1")==2
assert y.get("A")==2
assert y.get("P")==3
assert y.get(".")==1
assert y.get(4)== None

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago