Remember th

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.4: A Case Study: Constructing A Date Class
Problem 7E
icon
Related questions
Question

Instructions

  1. Write a function create_password() expects two parameters: pet_name (a string) and fav_number (an integer).

The function returns a new password generated using the following pattern:

fav_number followed by the pet_name followed by the star * and fav_number again (see the example below).

  1. Create a program that gets a pet name and a favorite number as input from the user, calls the above function, and then prints the output as shown below.

Example

Input:

Angel 3

Output:

Your new password is "3Angel*3".

Note that the double quotes are part of the output.

The assert in the provided template is checking that this function call is returning the correct value (i.e., a correctly-formed string).

assert create_password("Angel", 3) == "3Angel*3"

Hints

  • Remember that you cannot directly concatenate an integer and a string - you need to convert an integer into a string using either str() or by using f-strings.

Troubleshooting

  • If you are getting AssertionError make sure that your create_password() function is returning the correct value.
  • If you are failing the Unit Tests but passing all of the "Compare Output" tests: make sure that your create_password() function is returning the correct value. This error is likely due to the if __name__ == '__main__': block printing the right value, but the function create_password() is not creating/returning the correct value.

provided code:

def _(_):
    """
    The function expects
    param: var_name (var_type)
    The result is ...
    """

if __name__ == '__main__':
    # TODO: Type your code here. Your code must call the function.
    assert create_password("Angel", 3) == "3Angel*3"

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Asymptotic Analysis
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning