SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Value Returning Functions And Modules
Exercise:
Algorithm Workbench
Question:5 | ISBN:9780132576376 | Edition: 2

Question

Write a function named get_first_name that asks the user to enter his or her first name, and returns it.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The following function named get_first_name that asks the user to enter his or her first name, and returns it as follows:

def get_first_name():
    firstName = input("Enter your first name: ")
    return firstName

Explanation:

  • Create a function without any arguments called get_first_name.
  • Inside the capability, we utilize the information capability to incite the client to enter their most memorable name.
  • The firstName variable holds the input. In the end, the value of firstName is returned.
  • The user will be prompted to enter their first name when the get_first_name function is called, and the value they provide will be returned as the function's output.
0 0

Discussions

Post the discussion to improve the above solution.