Table of Contents
1. Write a function that takes an amount in dollars and the dollar-to-rupee conversion price; it then returns the amount converted to rupees. Create the function in both void and non-void forms.
2. Write a function to calculate the volume of a box with appropriate default values for its parameters. Your function should have the following input parameters:
3. Write a program to have the following functions:
4. Write a function that receives two numbers and generates a random number from that range. Using this function, the main program should be able to print three numbers randomly.
5. Write a function that receives two string arguments and checks whether they are same-length strings (returns True in this case otherwise false).
6. Write a function named nthRoot() that receives two parameters x and n and returns the nth root of x, i.e., x^(1/n). The default value of n is 2.
7. Write a function that takes a number n and then returns a randomly generated number having exactly n digits (not starting with zero). For example, if n is 2, then the function can randomly return a number 10-99, but 07, 02, etc., are not valid two-digit numbers.
8. Write a function that takes two numbers and returns the number that has the minimum one’s digit. For example, if numbers passed are 491 and 278, then the function will return 491 because it has the minimum one’s digit out of the two given numbers (491’s 1 is < 278’s 8).
9. Write a program that generates a series using a function which takes the first and last values of the series and then generates four terms that are equidistant. For example, if two numbers passed are 1 and 7 then the function returns 1, 3, 5, 7.
5. Write a function that receives two string arguments and checks whether they are same-length strings (returns True in this case otherwise false).
Short Answer: The function will compare the lengths of two string arguments and return True if they are of the same length; otherwise, it will return False.
Python def check_same_length_strings ( str1 , str2 ):
return len (str1) == len (str2)
# Test
print (check_same_length_strings( " hello " , " world " )) # False
print (check_same_length_strings( " apple " , " orange " )) # True
Explanation:
The function check_same_length_strings
compares the lengths of two string arguments using the len()
function.
It returns True if the lengths are the same, indicating that the strings are of the same length, otherwise, it returns False.