# Simple python Question.
============================
Usinginput(),ascertain whether or not a user wants to convert fahrenheit to celsius, or celcius to farenheit. Then have your python script do so, and output the answer.
Create a function called question_2 to calculate the sum of 2 given numbers, if the values are equal, then return thrice of their sum.
Create a function called question_3 that accepts 3 arguments. The function will compare the three arguments, and return the highest value.
Create a function called question_4 that accepts 2 arguments. The function will compare the two arguments, and returns only the 2nd argument’s value, only if the 2nd argument is more than double the 1st argument’s value.
When defining a function, you are able to call that same function inside of its own definition. This creates a “stack” of function calls known as recursion. One very important step to using a recursive function is known as the “base case,” and is required so that the function does not infinitely call itself during run time. (You may recall me programming our turtle to do something X amount of times using this technique).
-Create a function called facto_compute that computes the factorial of your argument “n”. Then using comments in your code, explain the base case, and explain step by step the journey of facto_compute(3).
#function that takes temprature and flag
#of type Boolean.
#if it is True that menas convert temprature in fahrenheit to
celsius
#otherwise convert temprature in celsius to fahrenheit
#it returns the respective converted temprature
def question_1(temp,flag):
if(flag == True):
temp_cel = (temp - 32) / 1.8
return temp_cel
else:
temp_fahr = (temp * 1.8) + 32
return temp_fahr
#function that returns the sum of 2 given numbers
#returns thrice of sum if 2 nums are equal
def question_2(one, two):
add = one + two
if(one == two):
return add*3
else:
return add
#function that retuns maximum of three values
def question_3(one, two, three):
if(one > two and one > three):
return one
elif(two > one and two >three):
return two
else:
return three
#function that returns the second arg
#if it is >= double of first arg else None
def question_4(one,two):
if(two >= one * 2):
return two
else:
return None
def facto_compute(n):
if(n ==1):
return 1
elif(n <=0):
return 0
else:
return n * facto_compute(n-1)
temp = float(input("Enter Temprature: "))
print("Enter y to Convert Temp in Fahrenheit to Celsius")
print("\tor")
print("Enter n to Convert Temp in celsius into Temp in
Fahrenheit")
choice = input("").strip().lower()
if(choice == "y"):
print("Temprature in Celsius:",question_1(temp,
True))
elif(choice == "n"):
print("Temprature in Fahrenheit:",question_1(temp,
False))
else:
print("Invalid Choice")
#question_2()
print("Sum of 10 + 12 =",question_2(10,12))
print("Sum of 10 + 10 =",question_2(10,10))
#question_3()
print("Maximum of 84,34,88 is :",question_3(84,34,88))
#question_4()
print("question_4(10,23): ", question_4(10,23))
#facto_compute()
print("Factorial of 10:",facto_compute(10))



# Simple python Question. ============================ Usinginput(),ascertain whether or not a user wants to convert fahrenheit to...
Use python!!! need to match the execution result that is provided. Part One – Keyword Arguments and Default Values Write an invoice function. The function will generate a simple invoice and will have two required arguments and two keyword arguments. The two required arguments are unitPrice and quantity. The first keyword argument is shipping, and it has a default value of 10. The second keyword argument is handling, and it has a default value of 5. Test it twice from...
Use python!!! need to match the execution result that is provided. Part One – Keyword Arguments and Default Values Write an invoice function. The function will generate a simple invoice and will have two required arguments and two keyword arguments. The two required arguments are unitPrice and quantity. The first keyword argument is shipping, and it has a default value of 10. The second keyword argument is handling, and it has a default value of 5. Test it twice from...
USING PYTHON! The second function you will write should be called ‘varOrd’. Your function should take two (2) arguments, an integer and a string. The function should return one (1) integer calculated as follows. If the input integer is 1, the function should return the sum of the return value of the ord() function on each character of the string (e.g., varOrd(1, ‘cat’) should return the result of ord(‘c’) + ord(‘a’) + ord(‘t’)). If the input integer is 2, the...
python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...
IT PYTHON
QUESTION1 Consider the following Python code, where infile.txt and outfile.txt both exist in the current directory 'z' ) 。1d = open ( ' infile. txt ' , for line in old: new.write (line) new.write') ne«.close () old.close) Which of the following options best describes the purpose or outcome of this code? O A copy of the file infile.txt is made (except in double line spacing) and saved as outfile.txt in the current directory. O A copy of the...
Create qz5.c to include all of the following function prototypes: void check1(char *, char, int *); void check2(char *, char, int *); void display(char, int); Then, implement main() to perform the tasks below: Define a 10-element char array with initial values of any lower case letters of your selection. Values can duplicate. Define a pointer that points to the above array. Print the array completely with double spaces before each character. See screenshot below for a sample. Call check1() with...
Python GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will create a textual menu that shows 3 choices. 1. Input class grade and number of units. 2....
Please answer this question using python programming only and provide a screen short for this code. Homework 3 - Multiples not less than a number Question 1 (out of 3) This homework is a SOLO assignment. While generally I encourage you to help one another to learn the material, you may only submit code that you have composed and that you understand. Use this template to write a Python 3 program that calculates the nearest multiple of a number that...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
Create a Python script file called hw12.py. Add your name at the top as a comment, along with the class name and date. Ex. 1. a. Texting Shortcuts When people are texting, they use shortcuts for faster typing. Consider the following list of shortcuts: For example, the sentence "see you before class" can be written as "c u b4 class". To encode a text using these shortcuts, we need to perform a replace of the text on the left with...