Quiz Q1 Create a function that takes the length, width, height (in meters) and output unit in which you want to see the answer and returns the volume of a pyramid in the correct unit. Notes: • The units used are limited to: millimeters, centimeters, meters and kilometers. • Ensure you return the answer and add the correct unit in the format cubic <unit>. T est Cases: • pyramidVolume(4, 6, 20, "centimeters") ➞ "160000000.000 cubic centimeters" • pyramidVolume(1843, 1823, 923, "kilometers") ➞ "1.034 cubic kilometers" • pyramidVolume(18, 412, 93, "millimeters") ➞ "229896000000000.000 cubic millimeters" Q2 You’ve been hired by an Automobile company to write a program to help the tax collector calculate vehicle taxes. Vehicle taxes are based on two pieces of information; the price of the vehicle and the vehicle type code. The formula of calculating the final price of an item is: Final Price = Item Price + Tax Amount Tax rates are in the table below Vehicle Type Vehicle Code Tax Rate Motorcycle M 6% Electric E 8% Sedan S 10% Van V 12% Truck T 15% After the tax has been calculated, the program should display the following on the screen; The final price on a vehicle of type xxx after adding the tax is $xxx. with xxx replaced by the vehicle type and $xxx with the final price. Your job is to write a function float taxCalculator(char type, float price); and then write the main function for taking the input from the user and then displaying the final output. Q3 A firm gets a request for creating a project for which a certain number of hours are needed. The firm has a certain number of days. During 10% of the days, the workers are being trained and cannot work on the project. A normal working day is 8 hours long. The project is important for the firm and every worker must work on it with overtime of 2 hours per day. Final answer in hours must be rounded down to the nearest integer (for example, 6.98 hours are rounded to 6 hours). Write a program that calculates whether the firm can finish the project on time and how many hours more are needed or left. You have to make a function projectTimeCalculation that takes needed hours, days that the firm has and number of workers as input and then returns the string as answer. Input Data The input data is read from the console and contains exactly three lines: • On the first line are the needed hours – an integer in the range of [0 ... 200 000]. • On the second line are the days that the firm has – an integer in the range of [0 ... 20 000]. • On the third line are the number of all workers – an integer in the range of [0 ... 200]. O utput Data Print one line on the console: • If the time is enough: " Yes!{the hours left} hours left.". • If the time is NOT enough: " Not enough time!{additional hours} hours needed.". Q4 Write a C++ program to print the appropriate activity depending on the variable temperature and humidity value. The table below assumes that the temperature can only be warm and cold, and the humidity can only be dry and humid. If temperature is If humidity is Print this activity warm dry Play tennis warm humid swim cold dry Play basketball cold humid Watch tv Write a C++ function named decideActivity that takes temperature and humidity as input and returns the appropriate activity according to the conditions. Q5 Jack is a teacher who needs a program that helps him to compile 8th class results. He has five subjects (English, Maths, Chemistry, Social Science, and Biology) marked in detail. Program asks the user to enter five subjects' marks, including student name a nd displays the total marks, percentage, grade (by percentage), and student name. Every subject has a total of 100 marks. Grading policy details are mentioned below. Percentage Grade 90 - 100 percentage A+ 80 - 90 percentage A 70 - 80 percentage B+ 60 - 70 percentage B 50 - 60 percentage C 40 - 50 percentage D Below 40 percentage F Your task is to create 2 functions. 1. float calculateAverage ( float marksEnglish , float marksMaths , float marksChemistry , float marksSocialScience , float marksBiology ) 2. string calculateGrade ( float average ) 1st function should take all the marks and then return the average of the marks then 2nd function should take the average and then return the grade as string. Q6 Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of service: regular and premium. Its rates vary, depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus the first 50 minutes are free. Charges for over 50 minutes are $0.20 per minute. Premium service: $25.00 plus: • For calls made during the day., the first 75 minutes are free; charges for more than 75 minutes are $0.10 per minute. • For calls made during the night, the first 100 minutes are free; charges for more than 100 minutes are $0.05 per minute. Y our program should prompt the user to enter a service code (type char), and the number of minutes the service was used. A service code of r or R means regular service; a service code of p or P means premium service. Treat any other character as an error . Your program should output the type of service, the number of minutes the telephone service was used, and the amount due from the user. For the premium service, the customer may be using the service during the day and the night(d or D for day and n or N for the night). Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night. Test case Q7 Write a Python program using dictionar y that takes a number as input and counts how many times each digit (0 – 9) appears in that number. The program should then display each digit along with its frequency. Example: Input: 1122334455 Output : 1 → 2 times 2 → 2 times 3 → 2 times 4 → 2 times 5 → 2 times Q8 You are given a dictionary in which keys are unique , but values may repeat . Your task is to invert the dictionary , meaning that each value should become a key in the new dictionary, and each key should become part of a list of keys that originally had that value. If multiple keys in the original dictionary have the same value , the inverted dictionary must store those keys together inside a list under that common value. Given the dictionary: { "a" : 1 , "b" : 2 , "c" : 1 } Both "a" and "c" have the value 1 , while "b" has the value 2 Therefore, the inverted dictionary should group "a" and "c" together: Output { 1 : [ "a" , "c" ], 2 : [ "b" ] } Write a Python program that: 1. Takes the original dictionary as input (fixed or user - defined). 2. Creates a new dictionary where: o Each unique value from the original dictionary becomes a key o The corresponding keys from the original dictionary are stored in a list 3. Displays the inverted dictionary. Q9 You are required to write a Python function that determines whether a given list of numbers is sorted in ascending order A list is considered sorted in ascending order if every element is less than or equal to the next element Create a function that: 1. Takes a list of numbers as input (either from the user or predefined). 2. Checks whether the list is sorted in ascending order. 3. Returns or prints : o "The list is sorted" if all elements follow ascending order. o "The list is not sorted" otherwise. Input: [ 1, 2, 3, 4, 5 ] Output: The list is sorted Input: [ 3, 1, 4, 2 ] Output: The list is not sorted Q10 You are given a list containing integer values . Your task is to separate these integers into two new lists based on whether they are even or odd Write a Python program that: 1. Takes a list of integers (either user input or predefined). 2. Creates two new lists : o Even List → contains all numbers divisible by 2 o Odd List → contains all numbers NOT divisible by 2 3. Prints both lists separately. Definition Reminder • A number is even if: • number % 2 == 0 • A number is odd if: • number % 2 != 0 Input List: [ 10, 21, 4, 45, 66, 93 ] Output: Even numbers : [10, 4, 66] Odd numbers : [21, 45, 93]