Computer Science
Write a function that takes amount-in-dollars and dollar-to-rupee conversion price; it then returns the amount converted to rupees. Create the function in both void and non-void forms.
Python
Python Functions
17 Likes
Answer
def convert_dollars_to_rupees(amount_in_dollars, conversion_rate):
amount_in_rupees = amount_in_dollars * conversion_rate
return amount_in_rupees
def convert_dollars_to_rupees_void(amount_in_dollars, conversion_rate):
amount_in_rupees = amount_in_dollars * conversion_rate
print("Amount in rupees:", amount_in_rupees)
amount = float(input("Enter amount in dollars "))
conversion_rate = float(input("Enter conversion rate "))
# Non-void function call
converted_amount = convert_dollars_to_rupees(amount, conversion_rate)
print("Converted amount (non-void function):", converted_amount)
# Void function call
convert_dollars_to_rupees_void(amount, conversion_rate)Output
Enter amount in dollars 50
Enter conversion rate 74.5
Converted amount (non-void function): 3725.0
Amount in rupees: 3725.0
Enter amount in dollars 100
Enter conversion rate 75
Converted amount (non-void function): 7500.0
Amount in rupees: 7500.0
Answered By
4 Likes
Related Questions
What is the output of following code fragments ?
def increment(n): n.append([49]) return n[0], n[1], n[2], n[3] L = [23, 35, 47] m1, m2, m3, m4 = increment(L) print(L) print(m1, m2, m3, m4) print(L[3] == m4)What will be the output of the following Python code ?
V = 25 def Fun(Ch): V = 50 print(V, end = Ch) V *= 2 print(V, end = Ch) print(V, end = "*") Fun("!") print(V)- 25*50!100!25
- 50*100!100!100
- 25*50!100!100
- Error
Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following input parameters :
(a) length of box ;
(b) width of box ;
(c) height of box.
Test it by writing complete program to invoke it.
Write a program to have following functions :
(i) a function that takes a number as argument and calculates cube for it. The function does not return a value. If there is no value passed to the function in function call, the function should calculate cube of 2.
(ii) a function that takes two char arguments and returns True if both the arguments are equal otherwise False.
Test both these functions by giving appropriate function call statements.