In this lab, you will: create a function according to the specifications check on the type practice if/else statement Instructions 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(word1, word2) that will: Confirm both word1 and word2 are of type str 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 . If they are not both strings, print the following: Incorrect argument type found. Expected strings. Then return False. Hint: Remember, printing and returning a value are different. You can print strings on-screen with the command print() and return a function's output with return.
In this lab, you will: create a function according to the specifications check on the type practice if/else statement Instructions 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(word1, word2) that will: Confirm both word1 and word2 are of type str 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 . If they are not both strings, print the following: Incorrect argument type found. Expected strings. Then return False. Hint: Remember, printing and returning a value are different. You can print strings on-screen with the command print() and return a function's output with return.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
In this lab, you will:
- create a function according to the specifications
- check on the type
- practice if/else statement
Instructions
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(word1, word2) that will:
- Confirm both word1 and word2 are of type str
- If they are both strings, compute the product of the two string lengths. Then print the following:
Both "<string 1>" and "<string 2>" are strings. The product of their lengths is <product of string lengths>.
and return <product of string lengths>.
- If they are not both strings, print the following:
Incorrect argument type found. Expected strings.
Then return False.
Hint: Remember, printing and returning a value are different. You can print strings on-screen with the command print(<string>) and return a function's output with return.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education