Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'll rate it up once you explain the logic. Here is my code. def word_mult(word1, word2): if (type(word1) == str) and (type(word2) == str): return

I'll rate it up once you explain the logic. Here is my code.

def word_mult(word1, word2): if (type(word1) == str) and (type(word2) == str): return len(word1) * len(word2) else: return False if __name__ == '__main__': word1 = input() word2 = input() if (type(word1) == str) and (type(word2) == str): print('Both "{}" and "{}" are strings.'.format(word1, word2)) print('The product of their lengths is .'.format(word_mult(word1, word2))) else: print('Incorrect argument type found. Expected strings.')

image text in transcribed

In this lab, we will practice writing functions that both display (ie: print) and return values. This will all be done in the word_mult() function below. Given two inputs, write a function word_mult(word, word2) that will: Confirm both word1 and word2 are of type str o If they are both strings, compute the product of the two string lengths. Then print the following: Both "" and "" are strings. The product of their lengths is ) and return a function's output with return. 295818.1713114 LAB ACTIVITY 5.17.1: Breakout Rooms: String Character Multiplier 4/5 Load default template... main.py 9# 10 # If they are not both strings, print the following: 11 # "Incorrect argument type found. Expected strings." 12 # Then return false 13 14 def word_mult(word, word2): 15 if (type (wordl) == str) and (type (word2) == str): 16 return len(word) * len(word) 17 else: 18 return false 19 if _name__ == '__main__': 29 wordi input() 21 word2 = input() 22 if (type (wordl) == str) and (type (word) == str): 23 print('Both "{}" and "{}" are strings.'.format(word, word)) 24 print('The product of their lengths is .'.format(word_mult(word, word2))) 25 else: 26 print('Incorrect argument type found. Expected strings.')

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago