Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5.8, Problem 32CP
Look at the following function definition:
def do_something(number):
return number * 2
a. What is the name of the function?
b. What does the function do?
c. Given the function definition, what will the following statement display?
print (do_something(10))
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
When calling a function with several arguments, parameter order matters.
A. Function calling another function
You have already seen a function that has called another function, but you may not
have paid close attention to it. In order to call a programmer-defined function inside
another programmer-defined function, you need to have the declaration of the
function that is being called before the declaration of the calling function.
In this program you will write a function of void return type named compare that
accepts an integer parameter named guess. This function will compare the value of
guess with a seeded randomly generated integer between 1 to 100, inclusive, and let
the user know what the random number was as well as whether the guess was larger
than, smaller than or equal to the random number.
NOTE THAT: You will NOT generate a random number inside the compare function.
Rather, you will write another function named getRandom of int return type to do it.
You will need to call getRandom from compare, no parameters are necessary.
Inside your main…
done in c++
Program Specifications:
Write a program that asks for a user's name and age, finds the ticket price based on the age, and prints out the user's name, age, and ticket price.
The program must define the following 3 functions and call them in the main function.
Create a function called getName that takes in no arguments and returns the name of the user.
Create a function called getAge that takes in the argument age and uses pass-by-reference to set the age of the user. Ensure that the user cannot put in an age that is negative or greater than 100.
Create a function called printTicket that takes in the user's name and age and does the following
○ If they are less than or equal to 13 years old set ticket_Price to 9.99.
○ If their age is greater than 13 and less than 65, set ticket_Price to 19.99.
○ If their age is greater than or equal to 65, set ticket_Price to 12.99.
○ Output to the console the user's name, age and ticket price.
Chapter 5 Solutions
Starting Out with Python (4th Edition)
Ch. 5.1 - What is a function?Ch. 5.1 - Prob. 2CPCh. 5.1 - How do functions help you reuse code in a program?Ch. 5.1 - How can functions make the development of multiple...Ch. 5.1 - How can functions make it easier for programs to...Ch. 5.2 - A function definition has what two parts?Ch. 5.2 - What does the phrase calling a function mean?Ch. 5.2 - When a function is executing, what happens when...Ch. 5.2 - Prob. 9CPCh. 5.4 - What is a local variable? How is access to a local...
Ch. 5.4 - What is a variables scope?Ch. 5.4 - Prob. 12CPCh. 5.5 - What are the pieces of data that are passed into a...Ch. 5.5 - What are the variables that receive pieces of data...Ch. 5.5 - Prob. 15CPCh. 5.5 - When a parameter is changed, does this affect the...Ch. 5.5 - The following statements call a function named...Ch. 5.6 - What is the scope of a global variable?Ch. 5.6 - Give one good reason that you should not use...Ch. 5.6 - Prob. 20CPCh. 5.7 - How does a value-returning function differ from...Ch. 5.7 - Prob. 22CPCh. 5.7 - Prob. 23CPCh. 5.7 - What does the following statement do? x =...Ch. 5.7 - What does the following statement do? print...Ch. 5.7 - What does the following statement do? print...Ch. 5.7 - What does the following statement do? print...Ch. 5.7 - What does the following statement do? print...Ch. 5.7 - When the random module is imported, what does it...Ch. 5.7 - What happens if the same seed value is always used...Ch. 5.8 - Prob. 31CPCh. 5.8 - Look at the following function definition: def...Ch. 5.8 - What is a Boolean function?Ch. 5.9 - What import statement do you need to write in a...Ch. 5.9 - Write a statement that uses a math module function...Ch. 5.9 - Write a statement that uses a math module function...Ch. 5 - A group of statements that exist within a program...Ch. 5 - A design technique that helps to reduce the...Ch. 5 - The first line of a function definition is known...Ch. 5 - You___a function to execute it. a. define b. call...Ch. 5 - A design technique that programmers use to break...Ch. 5 - Prob. 6MCCh. 5 - A ______ is a variable that is created inside a...Ch. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - Prob. 10MCCh. 5 - A variable that is visible to every function in a...Ch. 5 - Prob. 12MCCh. 5 - This is a prewritten function that is built into a...Ch. 5 - This standard library function returns a random...Ch. 5 - This standard library function returns a random...Ch. 5 - This standard library function returns a random...Ch. 5 - This statement causes a function to end and sends...Ch. 5 - This is a design tool that describes the input,...Ch. 5 - This type of function returns either True or...Ch. 5 - This is a math module function. a. derivative b....Ch. 5 - The phrase "divide and conquer" means that all of...Ch. 5 - Functions make it easier for programmers to work...Ch. 5 - Function names should be as short as possible.Ch. 5 - Calling a function and defining a function mean...Ch. 5 - A flowchart shows the hierarchical relationships...Ch. 5 - A hierarchy chart does not show the steps that are...Ch. 5 - A statement in one function can access a local...Ch. 5 - In Python, you cannot write functions that accept...Ch. 5 - In Python, you can specify which parameter an...Ch. 5 - You cannot have both keyword arguments and...Ch. 5 - Some library functions are built into the Python...Ch. 5 - You do not need to have an import statement in a...Ch. 5 - Complex mathematical expressions can sometimes be...Ch. 5 - A function in Python can return more than one...Ch. 5 - IPO charts provide only brief descriptions of a...Ch. 5 - How do functions help you to reuse code in a...Ch. 5 - Name and describe the two parts of a function...Ch. 5 - When a function is executing, what happens when...Ch. 5 - What is a local variable? What statements are able...Ch. 5 - What is a local variable's scope?Ch. 5 - Prob. 6SACh. 5 - Suppose you want to select a random number from...Ch. 5 - What statement do you have to have in a...Ch. 5 - What three things are listed on an IPO chart?Ch. 5 - What is a Boolean function?Ch. 5 - Prob. 11SACh. 5 - Write a function named times_ten. The function...Ch. 5 - Examine the following function header, then write...Ch. 5 - Look at the following function header: der...Ch. 5 - What will the following program display? def main...Ch. 5 - Look at the following function definition def...Ch. 5 - Write a statement that generates a random number...Ch. 5 - The following statement calls a function named...Ch. 5 - A program contains the following function...Ch. 5 - Write a function named times_ten that accepts a...Ch. 5 - Write a function named get_first_name that asks...Ch. 5 - Kilometer Converter The Kilometer Converter...Ch. 5 - Sales Tax Program Refactoring Programming Exercise...Ch. 5 - How Much Insurance? Many financial experts advise...Ch. 5 - Automobile Costs Write a program that asks the...Ch. 5 - Property Tax A county collects property taxes on...Ch. 5 - Calories from Fat and Carbohydrates A nutritionist...Ch. 5 - Stadium Seating There are three seating categories...Ch. 5 - Paint Job Estimator A painting company has...Ch. 5 - Monthly Sales Tax A retail company must file a...Ch. 5 - Feet to Inches The Feet to Inches Problem One foot...Ch. 5 - Math Quiz Write a program that gives simple math...Ch. 5 - Maximum of Two Values Write a function named max...Ch. 5 - Falling Distance When an object is falling because...Ch. 5 - Kinetic Energy In physics, an object that is in...Ch. 5 - Test Average and Grade Write a program that asks...Ch. 5 - Odd/Even Counter In this chapter, you saw an...Ch. 5 - Prime Numbers A prime number is a number that is...Ch. 5 - Prime Number List This exercise assumes that you...Ch. 5 - Future Value Suppose you have a certain amount of...Ch. 5 - Random Number Guessing Game Write a program that...Ch. 5 - Rock, Paper, Scissors Game Write a program that...Ch. 5 - Turtle Graphics: Triangle Function Write a...Ch. 5 - Turtle Graphics: Modular Snowman Write a program...Ch. 5 - Prob. 24PECh. 5 - Turtle Graphics: Checkerboard Write a turtle...Ch. 5 - Turtle Graphics: City Skyline Write a turtle...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Determine the components of reaction at A and the tension in the cable needed to held the 800-lb cylinder in eq...
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
In the previous chapter, Self-Test Question 16 described a class Person to represent a person. The class has in...
Java: An Introduction to Problem Solving and Programming (8th Edition)
2-1 List the five types of measurements that form the
basis of traditional ptane surveying-
Elementary Surveying: An Introduction To Geomatics (15th Edition)
What is hardware?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
What is the disadvantage of having too many features in a language?
Concepts Of Programming Languages
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.Similar questions
- Examine the following function header, and then write a statement that calls the function, passing 12 as an argument.def show_value(quantity):arrow_forward18. What is the return type of function id ? a. int b. float c. bool d. dictarrow_forwardYou cannot have both keyword arguments and non-keyword arguments in a function call.arrow_forward
- in C language pleasearrow_forwardProgramming technique exercise Question 1). Write a complete C++ program that helps the teacher to calculate the result of students in the test of Programming Technique. The program should perform the following tasks: • Write a function named getinput. This is a non-returning function. It takes the score of question 1, score of question 2, and score of question 3 as input parameters. the function should ask the user to enter the score (per 100) for each question. It sends all the values entered by the user in (c) back to the calling module through the use of reference parameters. • Write a function named dispTier. This is a non-returning function. It takes the total marks as an input parameter. The function should display the tier based on the conditions. Tier 3 = below 40%, tier 2 = below75%, tier 1=75% and above • Write a function named calcAverage. I It takes the number of students and total marks as input parameters.arrow_forwardWrite a function, named timesTen, that accepts an integer argument. When the function is called, it should display the product of its argument multiplied times 10.arrow_forward
- Code in C please. for this question you will write a function definition and a main function. implement the following function. char runmenu( ); \\display the program options and get the users selection (a, d, or q)) \\get and return the selection from the user \\declare all necessary variables \\you can decide what a,d, or q stand for add the main function with the function call to runmenuarrow_forwardWrite a function that parses a decimal number into an octal number. The function header is as follows: int dec2Octal(const int& decimal) Write a test program that prompts the user to enter a decimal number, uses the dec2Octal function to parse it into an equivalent octal number and displays the octal number.arrow_forwardWhat is the return type of a main function?arrow_forward
- ,- Write a void function definition for a function called update_cost. The function has two formal parameters: tax_rate, which is the amount of sales tax expressed as a percentage, and cost, which is the cost of an item before tax. The function changes the value of cost so that it includes sales tax.arrow_forwarddroparrow_forwardIn C++ A value-returning function a. must contain "return" followed by the value to be returned (or variable assigned to that value) b. must contain "return" followed by a constant c. must contain "value" followed by the value of the function d. must contain "void" followed by the value to be returned (or variable assigned to that value)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY