Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def charInWord(word, char): ''' -charInWord() takes in a parameter word and another parameter char and determines whether char is contained in word. -If word is

def charInWord(word, char): ''' -charInWord() takes in a parameter word and another parameter char and determines whether char is contained in word. -If word is not a string type, or if char is not a string type, the function should return None. -If word contains the letter char, the function should return True. Otherwise, it should return false. - Note: When char is of type string, it should be of length 1. For example, char will be a single letter like a or z. We will not test for cases where char is more than one character, like char = ab -*** Note: you will need to use a while loop and string indexing.*** -*** You will not get full credit if you use other loops or the in operator.*** '''

PLS ran the pytest AND TheWhile Loop is the only loop allowed rather than for loop

from lab03 import charInWord # Test cases for charInWord: def test_charInWord_1(): assert charInWord("word", "d") == True def test_charInWord_2(): assert charInWord("", "d") == False def test_charInWord_3(): assert charInWord(8, "d") == None def test_charInWord_4(): assert charInWord("word", True) == None def test_charInWord_5(): assert charInWord("abcde", "f") == False

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_2

Step: 3

blur-text-image_3

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

IBM Db2 11 1 Certification Guide Explore Techniques To Master Database Programming And Administration Tasks In IBM Db2

Authors: Mohankumar Saraswatipura ,Robert Collins

1st Edition

1788626915, 978-1788626910

More Books

Students also viewed these Databases questions

Question

Question 4 A copyright lasts for 7 0 years. True False

Answered: 1 week ago

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago