Concept explainers
- Include pseudocode that describes all steps required to solve the problem.
- Employ variable names that describe the values they store and adhere to Python naming conventions.
- Include additional comments as needed to annotate your code.
- Use correct spelling and grammar.
- Use f_strings to output variable values.
- Use the "dunders test" for __name__ equals __main__
1. Write a
EXAMPLE OUTPUT 1
3 is larger than 1 by 2
EXAMPLE OUTPUT 2
The integers are equal, both are 3
2. Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to one decimal place. Custom function f_to_c should be a value-returning function defined to take a Fahrenheit temperature as a parameter. This function should calculate the equivalent Celsius temperature and return it. In the main function, your program should:
- prompt the user to enter a temperature as an integer.
- indicate the temperature scale of the temperature just entered.
- call the appropriate function from the temps module.
- Use an f-string to display the equivalent temperature accurate to one decimal place.
EXAMPLE OUTPUT 1
Enter a temperature 32
Was that input Fahrenheit or Celsius c/f? f
32 Fahrenheit equals 0.0 Celsius
EXAMPLE OUTPUT 2
Enter a temperature 100
Was that input Fahrenheit or Celsius c/f? c
100 Celsius is 212.0 Fahrenheit
Program 1: The first program asks to create a Python module named temps.py
with two custom functions, f_to_c
and c_to_f
, for converting temperatures between Fahrenheit and Celsius.
Program 2: The second program uses the custom module temps.py
to create an interactive temperature converter. It prompts the user to enter a temperature and specify the scale (Celsius or Fahrenheit), then performs the conversion and displays the result accordingly
Step by stepSolved in 4 steps with 5 images
- I know you guys are using AI. Don't you dare give me AI generated answer or plagiarised answer. If I see these things I'll give you multiple downvotes and will report immediately.arrow_forwardA function named cube_volume has already been defined. It consumes a float value and returns a float value. Call the function cube_volume with an argument of 2.5 and assign the result to a variable named cube.(use Python)arrow_forwardQuestion6 - A number is called a Disarium when the sum of its digits in their respective order is the number itself. Create a function that determines whether a number is a Disarium or not. (In python) Examples is_disarium (75) → False # 7^1+ 5 ^ 2 = 7 + 25 = 32 is_disarium (135)· # 1^1+ 3 ^ 2 + 5 ^3 = 1+ 9 + 125 = 135 - True is_disarium (544) - False is_disarium (518) - True is_disarium (466) - False is_disarium (8) - Truearrow_forward
- Q6: Complete the function that takes in a number x, and returns the value 1 if x > 0, otherwise it is 0 - this is called a step function ]: def step_function(x): "given x compute the correct value to return. Note you need to include the return statement here""" II II II # your code herearrow_forwardWrite a flowchart and C code for a program that does the following: Declare an array that will store 9 values Use a for() statement to store user entered scores for all 9- holes Create a function and pass the array into the definition of the function to compute the total Use an accumulating total statement to compute the total score Display the overall total to the output screen so that the golfer can see if he won.arrow_forwardFill in the Blank Word GameThis exercise involves creating a fill in the blank word game. Try prompting the user to enter a noun,verb, and an adjective. Use the provided responses to fill in the blanks and then display the story.First, write a short story. Remove a noun, verb, and an adjective.Create a function that asks for input from the user.Create another function that will fill the blanks in the story you’ve just created.Ensure that each function contains a docstring.After the noun, verb, and adjective have been collected from the user, display the story that has beencreated using their input. use python to ode.arrow_forward
- ______ are values, variables or expressions inside the parentheses of a function call in python. A. Arguments B. Globals C. Parameters D. Locals arrow_forwardIn Python how would you return a value from a function?arrow_forwardJS You are writing a number guessing program where the player must try to guess the secret number 17. This function will take a player's guess and tell them if they are either right or whether they should guess higher or lower on their next turn Write a function named "higher_lower" that takes an int as a parameter and returns "higher" if 17 is greater than the input and "lower" if 17 is less than the input, and "correct" if 17 is equal to the input.arrow_forward
- Void functions do not return any value when they are called.True or falsearrow_forwarddef truth_value(integer): """Convert an integer into a truth value.""" # Convert 0 into False and all other integers, # including 1, into True if integer == 0: truth_value = False else: truth_value = True return truth_value Now, write a function that goes in the opposite direction of the truth_value() function. This new function should convert a truth value into an integer. In particular, True should be converted into 1 and False into 0. Name the new function integer_0_or_1(). All you need to include below is your definition of the function integer_0_or_1(). It will be tested automatically against relevant inputs. So include your function and nothing more.arrow_forwardPlease answer everything. I will rate your answers.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education