Answer:
Here is some pseudocode that outlines the steps for creating a program that calculates overall final marks and outputs the necessary grades for a desired overall mark:
DEFINE a function called "calculate_final_mark"
INPUT: grades (list), weights (list), desired_mark (float)
CREATE a variable called "overall_mark" and set it to 0
FOR each grade and weight in the grades and weights lists:
MULTIPLY the grade by the weight
ADD the result to the overall_mark
IF overall_mark equals the desired_mark:
OUTPUT "You have already achieved the desired mark."
ELSE:
CREATE a variable called "needed_mark" and set it equal to the desired_mark minus the overall_mark
OUTPUT "You need a" needed_mark "on your next assessment to achieve a" desired_mark "overall mark."
END the function
Here is the equivalent code in Python:
def calculate_final_mark(grades, weights, desired_mark):
overall_mark = 0
for grade, weight in zip(grades, weights):
overall_mark += grade * weight
if overall_mark == desired_mark:
print("You have already achieved the desired mark.")
else:
needed_mark = desired_mark - overall_mark
print(f"You need a {needed_mark} on your next assessment to achieve a {desired_mark} overall mark.")
How to write a java program that asks the user for grades of students. Once the user enters 0 (zero), the program should print the largest of the marks of the students.
Answer:
import java.util.Scanner;
public class GradeProgram {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the student grades: ");
int grade = sc.nextInt();
int largestGrade = 0;
while (grade != 0) {
if (grade > largestGrade) {
largestGrade = grade;
}
grade = sc.nextInt();
}
System.out.println("The largest grade is: " + largestGrade);
}
}
Explanation:
MTBF is a measurement of
A) the speed at which a storage device can read and write data
B) the number of digits used to store a computer file
C) the average length of a time a storage device can reliably hold data without it beginning to degrade
D) the average length of time between failures on a device
MTBF is a measurement of the average length of time between failures on a device. Thus, the correct option for this question is D.
What is MTBF in computers?MTBF stands for Mean time between failures. It is often utilized in order to measure the overall failure rates, for both repairable and replaceable/non-repairable products.
It governs the simplest equation for mean time between failure. It is as follows:
MTBF = total operational uptime between failures/number of failures.It is the predicted elapsed time between inherent failures of a mechanical or electronic system during the normal functioning of the computer system in order to detect an error.
Therefore, MTBF is a measurement of the average length of time between failures on a device. Thus, the correct option for this question is D.
To learn more about MTBF, refer to the link:
https://brainly.com/question/22231226
#SPJ1
Which of the following does NOT pair the statement with the corresponding output?
The statement that does not pair with the corresponding output is system.out.printin (a + b+ c). The correct option is statement A.
What is the output?Output is any information processed by and sent by a computer or other electronic device. Anything visible on your computer monitor screen, such as the words you write on your keyboard, is an example of output.
Outputs can be text displayed on the computer's monitor, sound from the computer's speakers, or a physical output such as a printed sheet of paper from a printer connected to the computer.
Therefore, the correct option is A, system.out.printin (a + b+ c).
To learn more about output, refer to the link:
https://brainly.com/question/13736104
#SPJ1
Read the excerpt below from the play Antigone by Sophocles and answer the question that follows.
ANTIGONE:
I did not think
anything which you proclaimed strong enough
to let a mortal override the gods
and their unwritten and unchanging laws.
They’re not just for today or yesterday,
but exist forever, and no one knows
where they first appeared.
What does the passage reveal about the beliefs of the ancient Greeks?
A. Some believed humans were the ultimate authority.
B. Some believed women were the ultimate authority.
C. Some believed men were the ultimate authority.
D. Some believed the gods were the ultimate authority.
Answer:
D. Some believed the gods were the ultimate authority.
Explanation:
you will need to back up your computer files.
Code to be written in python:
Correct code will automatically be awarded the brainliest
You had learnt how to create the Pascal Triangle using recursion.
def pascal(row, col):
if col == 1 or col == row:
return 1
else:
return pascal(row - 1, col) + pascal(row - 1, col - 1)
But there is a limitation on the number of recursive calls. The reason is that the running time for recursive Pascal Triangle is exponential. If the input is huge, your computer won't be able to handle. But we know values in previous rows and columns can be cached and reused. Now with the knowledge of Dynamic Programming, write a function faster_pascal(row, col). The function should take in an integer row and an integer col, and return the value in (row, col).
Note: row and col starts from 1.
Test Cases:
faster_pascal(3, 2) 2
faster_pascal(4, 3) 3
faster_pascal(100, 45) 27651812046361280818524266832
faster_pascal(500, 3) 124251
faster_pascal(1, 1) 1
def faster_pascal(row, col):
if (row == 0 or col == 0) or (row < col):
return 0
arr = [[0 for i in range(row+1)] for j in range(col+1)]
arr[0][0] = 1
for i in range(1, row+1):
for j in range(1, col+1):
if i == j or j == 0:
arr[i][j] = 1
else:
arr[i][j] = arr[i-1][j] + arr[i-1][j-1]
return arr[row][col]
Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs). Ex: If the input is: 10 the output is: 22.040000000000003 lbs Note: Your program must define the function def kilo_to_pounds(kilos)
Hello there!
def kilo_to_pounds(kilos):
____pounds = 2.204 * kilos
____return pounds
kilos = int(input())
print(kilo_to_pounds(kilos), 'lbs')
The program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds is in the explanation part.
What is programming?The process of carrying out a specific computation through the design and construction of an executable computer programme is known as computer programming.
Here is the completed program in Python:
def kilo_to_pounds(kilos):
pounds = kilos * 2.204
return pounds
# Main program
kilo_input = float(input("Enter weight in kilograms: "))
pounds_output = kilo_to_pounds(kilo_input)
print("Weight in pounds: ", pounds_output)
Thus, the kilo_to_pounds function takes a weight in kilograms as input and converts it to pounds using the conversion factor of 2.204.
For more details regarding programming, visit:
https://brainly.com/question/11023419
#SPJ2
Describe your academic and career plans and any special interests (e.g., undergraduate research, academic interests, leadership opportunities, etc.) that you are eager to pursue as an undergraduate at Indiana University. If you encountered any unusual circumstances, challenges, or obstacles in completing your education, share those experiences and how you overcame them.
Answer:
My academic and career plans are to pursue an undergraduate degree in business and minor in accounting. I am particularly interested in the finance, marketing, and management fields. After graduating, I plan to go on to pursue a Master's degree in Business Administration.
I am eager to pursue leadership opportunities at Indiana University, and would like to become involved in the student government. I am also interested in participating in undergraduate research, and exploring the possibilities of internships or other professional development experiences. Finally, I am looking forward to getting involved in extracurricular activities, such as clubs and organizations, to gain a better understanding of the business field and to network with other students and professionals.
Throughout my educational journey, I have had to overcome a few obstacles that have been made more difficult due to the pandemic. I have had to adjust to a virtual learning environment and find new ways to stay engaged in my classes. Additionally, I have had to learn how to manage my time more efficiently, which has been challenging due to the fact that I am also working part-time. Despite these difficulties, I have been able to stay motivated by setting goals and prioritizing my work. With determination and perseverance, I am confident that I can achieve my academic and career goals.
(PYTHON)
The instructions will be shown down below, along with an example of how the program should come out when finished. Please send a screenshot or a file of the program once finished as the answer.
Using the knowledge in computational language in JAVA it is possible program should come out when finished.
Writting the code:package numberofcharacters;
import java.util.ArrayList;
public class App {
public static void main(String[] args) {
String toCalculate = "123+98-79÷2*5";
int operator_count = 0;
ArrayList<Character> operators = new ArrayList<>();
for (int i=0; i < toCalculate.length(); i++){
if (toCalculate.charAt(i) == '+' || toCalculate.charAt(i) == '-' ||
toCalculate.charAt(i) == '*' || toCalculate.charAt(i) == '÷' ) {
operator_count++; /*Calculating
number of operators in a String toCalculate
*/
operators.add(toCalculate.charAt(i)); /* Adding that operator to
ArrayList*/
}
}
System.out.println("");
System.out.println("Return Value :" );
String[] retval = toCalculate.split("\\+|\\-|\\*|\\÷", operator_count + 1);
int num1 = Integer.parseInt(retval[0]);
int num2 = 0;
int j = 0;
for (int i = 1; i < retval.length; i++) {
num2 = Integer.parseInt(retval[i]);
char operator = operators.get(j);
if (operator == '+') {
num1 = num1 + num2;
}else if(operator == '-'){
num1 = num1 - num2;
}else if(operator == '÷'){
num1 = num1 / num2;
}else{
num1 = num1 * num2;
}
j++;
}
System.out.println(num1); // Prints the result value
}
}
See more about JAVA at brainly.com/question/29897053
#SPJ1
Write an expression that will cause the following code to print "greater than 20" if the value of user_age is greater than 20.
Answer:
if user_age > 20:
print("greater than 20")
Explanation:
You are given a design board with four input pins a 4-bit INDATA,
1-bit Load,Enable, and Clock; and one output, a 4-bit OUTDATA.
Build a sequential circuit that contains a register (Don’t forget to
trigger that register by the FALLING edge of the clock, Logisim’s default
is the opposite!).
The register is updated every clock cycle in which Enable is up. If
Load is down, the register is incremented, otherwise it is loaded with the
data asserted on the INDATA pin.
The register data output should be connected with the output pin
OUTDATA.
The steps to Build a sequential circuit that contains a register is given below
The first step is to connect the 4-bit INDATA input to the data input of a 4-bit register.Next, we need to connect the Load and Enable inputs to a multiplexer. The multiplexer will be used to select between the INDATA input and the output of the register.The multiplexer output should be connected to the input of the register.We also need to create an AND gate that will be used to trigger the register on the falling edge of the clock. The AND gate should have the Clock input as well as the Enable input as its inputs.The output of the AND gate should be connected to the clock input of the register.The output of the register should be connected to the OUTDATA output.Create a NOT gate and connect the Load input to it, and connect the output of the NOT gate to one of the multiplexer input.Connect the output of the register to the second input of the multiplexer.What is the design board about?To build a sequential circuit that contains a register, we can use a combination of logic gates, flip-flops, and multiplexers.
In the above way, the register will be updated every clock cycle in which the Enable input is high. If the Load input is low, the multiplexer will select the output of the register and it will be incremented.
Otherwise, the multiplexer will select the INDATA input and the register will be loaded with the data asserted on the INDATA pin. The output of the register will be connected to the OUTDATA output, providing the register data.
Learn more about design board from
https://brainly.com/question/28721884
#SPJ1
use router,switches and Hubs to design a simple network for maendeleo institute of Technology having 240 employees.The institute have five department: computer science has 100 employees ,information technology 60 employees ,Account 40 employees ,Human resource has 20 employees and marketing has 20 employees . Require: .network topology showing five network that corresponding to five department .use class C IP addresses (example 192.168.10.0/24) to show subnet ID and broadcast ID of each department , the IP address must not overlap .consider scalability .Give reason for your choice /decision
Answer:
To design a simple network for Maendeleo Institute of Technology with 240 employees, we could use a combination of routers, switches, and hubs.
Our network would consist of five separate networks, one for each department at the institute. We would use class C IP addresses, with a subnet mask of /24, to create the following subnets:
Computer Science department: 192.168.10.0/24
Information Technology department: 192.168.11.0/24
Account department: 192.168.12.0/24
Human Resource department: 192.168.13.0/24
Marketing department: 192.168.14.0/24
Each department would be connected to the network via a switch, which would allow for communication within the department and with other departments as needed. A router would be used to connect the individual department networks to the wider internet, and would also serve as a firewall to protect the network from external threats.
We would also include a hub in the network to allow for communication between devices within a department, as well as to provide additional connectivity and scalability.
Overall, our network design would provide each department with its own separate network, with the ability to communicate with other departments as needed. It would also be scalable, allowing for the addition of new devices and departments as the institute grows. The use of class C IP addresses and a /24 subnet mask would ensure that IP addresses do not overlap, ensuring efficient and reliable communication within the network.
The method of presentation refers to the planning process for the presentation. the information chosen for the presentation. how the presentation topic will be introduced. how the presentation will be delivered.
An automotive company tests the driving capabilities of its self driving car prototype. They Carry out the test on various types of roadways specifically a racetrack chill rack and dirt road what are the examples of fair or unfair practices
It is to be noted that testing a self-driving car prototype on various types of roadways, such as a racetrack, hill rack, and dirt road, can be considered fair practice. It would only be unfair practice if the lives and property of humans are put at risk during the testing.
What is unfair practice?Unfair practices are behaviors that are neither just or fair. It would be deemed unjust to treat someone differently because of their color or gender, for example. Cheating or violating regulations to get an edge over others is also included. To develop a fair and just society, it is critical to constantly treat people with fairness and respect.
In this scenario, it is evident that endangering human life and property is unethical behavior.
Learn more about Unfair Practices:
https://brainly.com/question/14700715
#SPJ1
Workstations are usually applied for scientific, mathematical, and engineering calculations and computer aided-design and computer aided- manufacturing. a. False b. True
Workstations are usually applied for scientific, mathematical, and engineering calculations and computer aided-design and computer aided- manufacturing is True
What is Workstations?Workstations are specialized computers that are designed for high-performance and resource-intensive tasks such as scientific, mathematical, and engineering calculations, computer-aided design (CAD), and computer-aided manufacturing (CAM).
Therefore, They typically have faster processors, more memory, and better graphics capabilities than general-purpose computers, which allows them to handle the complex tasks required in these fields.
Learn more about Workstations from
https://brainly.com/question/9958445
#SPJ1
The user is able to input grades
and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for multiple courses as well. Lists are allowed.
Name of person
Number of courses
Course ID
Grades and Weights in various categories (Homework, Quiz, and Tests)
Enter grades until -1 is entered for each category
Final Grade before exam
Calculate to get a desired mark (using final exam)
Output all courses
Answer:
Here is an example of how you could write a program to perform the tasks described:
# Store the student's name and number of courses
name = input("Enter the student's name: ")
num_courses = int(input("Enter the number of courses: "))
# Create an empty list to store the course data
courses = []
# Loop through each course
for i in range(num_courses):
# Input the course ID and initialize the total grade to 0
course_id = input("Enter the course ID: ")
total_grade = 0
# Input the grades and weights for each category
print("Enter grades and weights for each category (enter -1 to finish)")
while True:
category = input("Enter the category (homework, quiz, test): ")
if category == "-1":
break
grade = int(input("Enter the grade: "))
weight = int(input("Enter the weight: "))
# Calculate the contribution of this category to the total grade
total_grade += grade * weight
# Store the course data in a dictionary and add it to the list
course_data = {
"id": course_id,
"grade": total_grade
}
courses.append(course_data)
# Input the final grade before the exam
final_grade_before_exam = int(input("Enter the final grade before the exam: "))
Flowchart of Accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: density 1⁄4 mass / volume.
Below is a simple flowchart that shows the process of calculating the volume of an object using its mass and density:
+-----------------------------+
| Input: Mass (m), |
| Density (d) |
+-----------------------------+
|
|
+-----------------------------+
| Volume = Mass / Density |
+-----------------------------+
|
|
+-----------------------------+
| Output: Volume (v) |
+-----------------------------+
What is the Flowchart about?The flowchart I provided shows the basic process of calculating the volume of an object using its mass and density. The process starts with the input of the object's mass and density. The mass is typically given in grams and the density is given in grams per cubic centimeter.
The next step is to calculate the volume of the object. This is done by using the formula for density, which states that density is equal to mass divided by volume. So, to find the volume, we divide the mass of the object (in grams) by its density (in grams per cubic centimeter). This formula can be written as:
volume = mass / density
Finally, the calculated volume is then output, which is typically given in cubic centimeters.
Note that:
density = mass/volume.
Density = mass / volume
Learn more about Flowchart from
https://brainly.com/question/6532130
#SPJ1
np.arange(5,8,1) what output will be produced?
Answer: [5 6 7]
Explanation: The np.arange takes in three parameters ->start,stop,step.
Hence, since we our range is 5 to 8, incrementing by 1 until we reach 8, giving us a list -> [5,6,7]
what is the main objective of the administrator when creating and assigning storage accounts to users?
Note that the main objective of the administrator when creating and assigning storage accounts to Users is "to provide them with a secure and reliable method of storing and accessing their data, while also maintaining control and visibility over the data and its usage. "
What is an Administrator in IT?IT administrators, also known as system administrators, configure and manage the computers, servers, networks, corporate software, and security systems of a business. They also assist the organization stay comply with cybersecurity rules by optimizing internal IT infrastructure for increased efficiency.
A competent administrator must understand networks and how to handle network problems. Basic hardware expertise is required. Understanding of backup, restoration, and recovery techniques. Excellent knowledge of permissions and user management
Learn more about Storage Accounts:
https://brainly.com/question/29929029
#SPJ1
3. Describe how homes and businesses use networks.
These tools protect networks from external threats.
A) firewalls
B) routers
C) antivirus software
D) VPN
Answer:
for safety everyone is needed, read the explanation
Explanation:
These tools protect networks from external threats.
A) firewalls
B) routers
C) antivirus software
D) VPN
the firewall, which can be installed in the pc but some routers also have it.
An antivirus is certainly needed, an antimalware is missing from the list, which is essential, for the VPN it is also useful to make believe you are connected in one place and instead you are in another, so I would say that all are needed for PC security
What is one advantage that typing has compared to writing by hand?
•It can be done anywhere there's paper.
•Each person's typing has its own individual personality
•There's no special equipment needed.
•It's easier to make corrections.
Answer: Typing encourages verbatim notes without giving much thought to the information.
Answer: D its easier to correct mistakes
Explanation:
Which benefits does the cloud provide to start-up companies without acccess to large funding
Answer:Among other things, the fact that anyone can connect to such a server from their home and work on something remotely
Explanation:
_______ is the assurance that you can rely on something to continue working properly throughout its lifespan.
A) Reliability
B) Raid
C) P/E cycle
D) MTBF
Demonstrate the Max() functio with example in ms excel
Make sure there is at least one blank cell underneath the list of integers you've chosen = MAX since this will insert a ready-to-use formula in a cell below the chosen range (C2:E7).
What does the term Max mean?The highest-valued item, or the item with the highest value within an iterable, is returned by the max() method. If the values are strings, then the comparison is done alphabetically.
Give an example of the Max () function's purpose.Any type of numeric data can have its maximum value returned by the MAX function. The slowest time in a race, the most recent date, the highest percentage, the highest temperature, or the biggest sales amount are just a few examples of the results that MAX can return. Multiple arguments are taken by the MAX function.
To know more about ms excel visit:-
https://brainly.com/question/20395091
#SPJ1
Code to be written in Python
Correct answer will be awarded Brainliest
In this task, we will be finding a possible solution to number puzzles like 'SAVE' + 'MORE' = 'MONEY'. Each alphabet represents a digit. You are required to implement a function addition_puzzle that returns a dictionary containing alphabet-digit mappings that satisfy the equation. Note that if there are multiple solutions, you can return any valid solution. If there is no solution, then your function should return False.
>>> addition_puzzle('ANT', 'MAN', 'COOL')
{'A': 8, 'C': 1, 'L': 9, 'M': 6, 'N': 7, 'O': 5, 'T': 2}
>>> addition_puzzle('AB', 'CD', 'E')
False
Explanations:
ANT + MAN = COOL: 872 + 687 = 1559
AB + CD = E: The sum of two 2-digit numbers must be at least a two-digit number.
Your solution needs to satisfy 2 conditions:
The leftmost letter cannot be zero in any word.
There must be a one-to-one mapping between letters and digits. In other words, if you choose the digit 6 for the letter M, then all of the M's in the puzzle must be 6 and no other letter can be a 6.
addition_puzzle takes in at least 3 arguments. The last argument is the sum of all the previous arguments.
Note: The test cases are small enough, don't worry too much about whether or not your code will run within the time limit.
def addition_puzzle(*args):
pass # your code here
Answer:
Here is one possible solution to this problem in Python:
from itertools import permutations
def addition_puzzle(*args):
# Get all permutations of the digits 0-9
digits = list(range(10))
all_permutations = list(permutations(digits))
# Iterate through each permutation
for perm in all_permutations:
# Create a dictionary mapping each alphabet to a digit
mapping = {alphabet: digit for alphabet, digit in zip(args[0], perm)}
if all(mapping[alphabet] != 0 for alphabet in args[0]):
# Check if the sum of the numbers is equal to the last argument
num1 = int(''.join(str(mapping[alphabet]) for alphabet in args[1]))
num2 = int(''.join(str(mapping[alphabet]) for alphabet in args[2]))
if num1 + num2 == int(''.join(str(mapping[alphabet]) for alphabet in args[3])):
return mapping
# If no solution is found, return False
return False
print(addition_puzzle('ANT', 'MAN', 'COOL'))
print(addition_puzzle('AB', 'CD', 'E'))
Explanation:
This solution first generates all possible permutations of the digits 0-9 using the permutations function from the itertools module. Then, it iterates through each permutation and creates a dictionary mapping each alphabet to a digit. It checks if the leftmost letter in any word is not zero and if the sum of the numbers is equal to the last argument. If both conditions are satisfied, it returns the mapping. If no solution is found after iterating through all permutations, it returns False.
What did the police threaten to do?
Answer:
fire?
Explanation:
Why does trust usually break down in a designer-client relationship?
A lack of service
B lack of privacy
C lack of communication
D lack of contract
Trust is usually broken down in a designer-client relationship due to a lack of service. Thus, the correct option for this question is A.
How do you end a client relationship?You would end a client relationship by staying calm, rational, and polite. Apart from this, reasons for terminating the relationship, but keep emotion and name-calling out of the conversation.
Follow-up with a phone call. You can start the process with an email, but you should follow up with a phone call in order to talk your client through the process and answer any questions.
But on contrary, one can build trust with clients by giving respect to them, Admit Mistakes and Correct Ethically, listening to them, listening to their words first followed by a systematic response, etc.
Therefore, trust is usually broken down in a designer-client relationship due to a lack of service. Thus, the correct option for this question is A.
To learn more about Client relationships, refer to the link:
https://brainly.com/question/25656282
#SPJ1
My code doesn't give me the right output: I have to use the Python input command, and the number could be a decimal fraction, such as 6.5, so I should use floating point numbers?
I need to have a loop that repeats six times, with a routine in the middle of the loop to get the user input as a floating point number and add the number to a sum.
Can someone check it for me?
score_list = [ input("Judge No {} :score ".format(num+1)) for num in range(6)]
int_accumilator :int = 0
for score in score_list:
if(score > 10 ):
print("i only like numbers within the 0-10 range !")
exit()
int_accumilator+= score
print("the average score is ...", int_accumilator/ len(score_list))
Answer:
def get_score(judge_num: int) -> float:
"""
Asks the user for the score of a single judge and returns it.
"""
score = float(input(f"Score for Judge {judge_num}: "))
return score
def calculate_average(scores: list[float]) -> float:
"""
Calculates the average score given a list of scores.
"""
return sum(scores) / len(scores)
# Initialize the total score to 0
total_score = 0
# Initialize an empty list to store the scores of the judges
scores = []
# Loop through each judge
for judge_num in range(1, 7):
# Get the score for the current judge
score = get_score(judge_num)
# Add the score to the total score
total_score += score
# Append the score to the list of scores
scores.append(score)
# Calculate the average score
average_score = calculate_average(scores)
# Print the average score
print(f"The average score is: {average_score:.2f}")
Code to be written in python:
Correct answer will get brainliest :)
Mr Wu has been going to work every day by taxi for many years. However, the taxi fare has been increasing rather quickly in recent years. Therefore, he is considering driving to work instead. One of the costs for driving is the parking fee. The parking rates of the car park at Mr Wu's workplace are as shown as below:
Weekdays:
$2 per hour between 4am and 7am
$1.20 per half hour between 7am and 6pm
$5 per entry after 6pm
Saturdays:
$2.50 per hour between 4am and 7am
$1.50 per half hour between 7am and 6pm
$7 per entry after 6pm
Sunday: Flat rate of $5 per entry
For all days, there is a grace period of 10 minutes.
The car park opens between 4am and 12 midnight daily. We assume vehicles are magically ejected at midnight.
There is a 10% surcharge on weekdays and a 20% surcharge on Saturdays for vehicles who park for more than 10 hours. There are no surcharges on Sunday.
There is an additional fee of $3 for exiting after 10pm on any day.
Your task is to write a function compute_fee(day, time_in, time_out) that computes the parking fee, where day is an integer between 1 and 7, with 7 representing Sunday, while time_in and time_out are integer values in a 24-hour format - e.g. 700 for 7am and 2359 for 11:59pm. Assume all input is valid.
Below are a few examples of how the fee is calculated:
Example 1: Tuesday, 4:29am to 7:50am.
• 4:29am to 7am is charged as 3 1-hour slots: $2.00 * 3 = $6.00
• 7am to 7:50am is charged as 2 30-minute slots: $1.20 * 2 = $2.40
• Total fee = $6.00 + $2.40 = $8.40
Example 2: Saturday, 7:01am to 7:49pm.
• 7:01am to 6pm is charged as 22 30-minute slots: $1.50 * 22 = $33.00
• 6pm to 7:49pm is charged as one entry: $7.00
• 20% Surcharge for parking more than 10 hours: ($33.00 + $7.00) * 20% = $8.00
• Total fee = $33.00 + $7.00 + $8.00 = $48.00
Example 3: Sunday, 3pm to 10:01pm.
• 3pm to 10:01pm is charged as one entry: $5.00
• Additional fee for exiting after 10pm: $3.00
• Total fee = $5.00 + $3.00 = $8.00
Example 4: Thursday, 11:49pm to 11:59pm.
• Grace period
• Total fee = $0.00
Example 5: Monday, 12pm to 10:01pm.
• 12pm to 6pm is charged as 12 30-minute slots: $1.20 * 12 = $14.40
• 6pm to 10:01pm is charged as one entry: $5.00
• 10% Surcharge for parking more than 10 hours: ($14.40 + $5.00) * 10% = $1.94
• Additional fee for exiting after 10pm: $3.00
• Total fee = $14.40 + $5.00 + $1.94 + $3.00 = $24.34
def compute_fee(day, time_in, time_out):
"""Your code here"""
Test Cases:
compute_fee(2, 429, 750) 8.4
compute_fee(6, 701, 1949) 48
compute_fee(7, 1500, 2201) 8
compute_fee(4, 2259, 2301) 0
compute_fee(1, 1200, 2201) 24.34
Here is the requested Python function that computes the parking fee based on the given information: