Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to use while function to pytest from labo3 import char InWord # Test cases for char InWord: def test_char InWord_10): assert char InWord(word, d)

image text in transcribed
How to use while function to pytest
image text in transcribed
image text in transcribed
from labo3 import char InWord # Test cases for char InWord: def test_char InWord_10): assert char InWord("word", "d") == True def test_char InWord_2(): assert char InWord("", "d") == False def test_char InWord_30: assert char InWord(8, "d") == None def test_char InWord_40): assert char InWord("word", True) == None def test_char InWord_50): assert char InWord("abcde", "f") == False This file contains several incomplete function definitions with stub # values. Lab3 tests.py should have tests to check if the functions are correct. # Your assignment is to complete each function according to the # functions descriptions. # Once you complete a function, use pytest on the test functions # in labo3_tests.py to see if your functions are working correctly def char InWord(word, char): -char InWord() 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. *** return "stub" This file contains several incomplete function definitions with stub # values. labo3_tests.py should have tests to check if the functions are correct. # Your assignment is to complete each function according to the # functions descriptions. # Once you complete a function, use pytest on the test functions * # in labo3_tests.py to see if your functions are working correctly def char InWord(word, char): -char InWord() 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. *** return "stub

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions