Question: Using the provided code below, how can I implement the assertTrue or assertEqual function to handle the failed test? Failed test / error function to
Using the provided code below, how can I implement the assertTrue or assertEqual function to handle the failed test?
Failed test error function to be fixed:
ZigZag
Write a function zigzag that takes two parameters, a string, and an integer kIt should return a string that has the parameter string spanning k lines in a zigzag pattern. You may assume the string is all on one line and has letters, digits, punctuation, and spaces only. So tabsnewlines and other control characters are excluded. Note this should be one long string, so use
where needed.
For example, with the input "ZigZagString" and k should return the string:
Z a r
i Z g t i g
g S n
Provided Code:
# Uses the import function to import unittest module
import unittest
# Creates a class called TestFunctions from unittest module
# Utilizes the unittest framework
class TestFunctionsunittestTestCase:
# Creates a function called testisprime, pass one parameter called self
# Tests for prime numbers
def testisprimeself:
# Utilizes the assertTrue or assertFalse to test the boolen logic of a given integer
# Tests whether the integer is prime or composite number
self.assertTrueisprime
self.assertTrueisprime
self.assertTrueisprime
self.assertTrueisprime
self.assertTrueisprime
self.assertFalseisprime
self.assertFalseisprime
self.assertFalseisprime
self.assertFalseisprime
self.assertFalseisprime
# Creates a function called testisanagram, pass one parameter called self
# Tests two strings to determine if they are anagrams
def testisanagramself:
# Utilizes the assertTrue or assertFalse to test the boolen logic for the given strings
# Tests whether the strings are anagrams
self.assertTrueisanagramlisten "silent"
self.assertTrueisanagramtriangle "integral"
self.assertFalseisanagramapple "pale"
self.assertFalseisanagramhello "bello"
self.assertTrueisanagramClint Eastwood", "Old West Action"
# Creates a function called testisanagramset, pass one parameter called self
# Tests a list of strings to determine if they are anagrams
def testisanagramsetself:
# Utilizes the assertTrue or assertFalse to test the boolen logic for a given list of strings
# Tests whether the strings are anagrams
self.assertTrueisanagramsetlisten "silent", "enlist"
self.assertTrueisanagramsettriangle "integral"
self.assertFalseisanagramsetapple "pale"
self.assertTrueisanagramsetClint Eastwood", "Old West Action"
self.assertFalseisanagramsethello "bello", "mellow"
# Creates a function called testispalindrome, pass one parameter called self
# Tests a word or phrase to determine if the strings are palindrome
def testispalindromeself:
# Utilizes the assertTrue or assertFalse to test the boolen logic for a given strings
# Tests whether the strings are palindromes
self.assertFalseispalindromeA man, a plan, a canal, Panama"
self.assertTrueispalindromeracecar
self.assertFalseispalindromehello
self.assertTrueispalindromeWas it a car or a cat I saw"
self.assertTrueispalindromeNo lemon, no melon"
# Creates a function called testzigzag, pass one parameter called self
# Tests a string and integer value
def testzigzagself:
# Utilizes the assertTrue or assertFalse
ZigZag
Write a function zigzag that takes two parameters, a string, and an integer kIt should return a string that has the parameter string spanning k lines in a zigzag pattern. You may assume the string is all on one line and has letters, digits, punctuation, and spaces only. So tabsnewlines and other control characters are excluded. Note this should be one long string, so use
where needed.
For example, with the input "ZigZagString" and k should return the string:
Z a r
i Z g t i g
g S n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
