please code in python the question is in the image
Q: 1. Write a class called Bicycle, which contains two attributes, gear, which describes the type of…
A: class ByCycle: def __init__(self,a,b): self.__gear=a self.__speed=b…
Q: e in Python.
A: given - Build a web crawler function that starts with a URL representing a topic (a sport, your…
Q: 3. Tree traversal is the process of visiting each node in a tree data structure. Tree traversal also…
A: python program to build/insert ino binary search tree and performing pre order traversal of the…
Q: Write a program that will get a collection of n numbers from the user. If the user entered 0 or a…
A: The program is written in Python. Check the program screenshot for the correct indentation. Please…
Q: createaVehicleRatescalculatorforAA. The purpose of a Vehicle Rates Calculator is to calculate how…
A: Required: You will need to complete the following objectives as a Python Application 1. When the…
Q: Write a function matrix1n() that gets an integer number (n) as parameter and returns a NumPy ara The…
A: The following python code will input the value of integer n. The code will create the matrix as…
Q: 8. Write a program that plays Rock-Paper-Scissors with the user and displays the cumulative score.…
A: The asked python program has been coded in the next step.
Q: how do i comment my name at the top in python pleas
A: Introduction: Comment: Useful to explain the code/program Way to make code more readable and…
Q: 6. Averaging a) Define a function average() with a parameter grades that can accept an arbitrary…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: Write a Python program that reads each line of an input file temperatures.txt that consists of a…
A: Please find the code below::
Q: St below using the concept of Benford's Law ate this law. Flow will be like this: _array = 1 to 1000…
A:
Q: Exercise 4: a Python program that converts temperature Fahrenheit to Celsius and Celsius to…
A: please find the screenshots of output and the code . 1.code : #the following function converts the…
Q: Write a function called count_items() that takes a list and returns a dictionary that contains the…
A: Problem Statement: Define function count_items() that takes a list and returns a dictionary that…
Q: 23.11 LAB: Toll calculation Toll roads have different fees based on the time of day and on weekends.…
A: Nested if-else is used in function calc_toll() to return toll fee as per details mentioned in the…
Q: Sorry about that can you translate it into python
A: According to your requirement you need in code in python.
Q: Create python code
A: Inheritance is the concept which allows us to define a class that inherits all the methods and…
Q: Write a Python program that inputs five positive integer numbers, finds their maximum and sort them…
A: def getValue(): # getValue function print("Please input 5…
Q: Show that if and only if DFS(Depth-first Search) finds no back edges, the graph being traversed is…
A: Python programming : Python is a deciphered, significant level and broadly useful programming…
Q: This is for Python code.
A: Solution:#Define functiondef twoscomp(n): #Declare empty variable comp = "" #Loop…
Q: Working with users in python
A: def is_this_digit(input_line):# if input_line is in between "0" and "9",then return Trueif…
Q: Question 4. From the following figure, detect only horizontal lines and display them. The input and…
A: import numpy as npimport cv2 gray = cv2.imread('input.jpg')edges =…
Q: Have the function CaesarCipher (str, num) take the ste parameter and perform a Caesar Cipher shift…
A: Define the function CaesarCipher with two parameters, strParam (string) and num (integer). Create…
Q: 2. Loop and Input a) Request two numbers, n1 and n2 from the console. b) n1 and n2 can be any…
A: Code: print("\n\nUSING WHILE LOOP") lower = int(input("\nEnter the lower bound: "))upper =…
Q: 1. Find the momentum, kinetic energy, and total energy of a proton moving at a speed of 0.756c.
A: - We need to code the provided situation in python.
Q: 3. An electron and a proton are each accelerated starting from rest through a potential difference…
A: Input : Potential difference = 10.0 Mv Output : Momentum Kinetic energy
Q: 4. Write a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating…
A: The range(n) function is a Python built-in function that generates a sequence of the numbers from 0…
Q: Write a program that take inputs from user to make and use a for loop to print the number (choose…
A: Note: The below program has been written to print the prime numbers between the range 20 to 45 using…
Q: 2. Derive the three-point formula for the second-order derivative with combination of fi-1» fy and…
A: 1)what will be the code in python derive the three-point formula for the second-order derivative…
Q: A half-life is the amount of time it takes for a substance or entity to fall to half its original…
A: Input the weight at start Calculate weights for every 6 hours Display weights at requested intervals
Q: A food-delivery company charges service fee based on this rule: It will charge 15% of the total…
A: GIVEN:
Q: QUESTION 2 Write one line of code ONLY. Print the value of gpa and its data type in two separate…
A: Step-1: Start Step-2: Declare a variable gpa with value 99.99 Step-3: Print the value of gpa Step-4:…
Q: TASK 3 (25 points) [Testing: Variables and expression, strings, conditional-statements, loops]…
A:
Q: (Buttons and radio buttons) Write a program that uses radio buttons to select back- ground colors…
A: Given: Write a program that uses radio buttons to select background colors for text, as shown in…
Q: •Develop a program that has an empty list. Then, have it ask a user five times (use a while loop) to…
A: Introduction: In this question, we are asked to write a python program to enter the 5 names by user…
Q: im using python for this code
A: I have done the code using Python 3.
Q: Give an example from your own idea, of a program that use a void function (does not return a value),…
A: The simplest example of a python void function is : def add(num1, num2): print("Sum = ", num1 +…
please code in python
the question is in the image
Step by step
Solved in 3 steps with 1 images
- Define a function called get_total_cost(items_dict, items_list) which takes two parameters as input. The first parameter is a dictionary where the keys represent the name of an item for sale, and the values represent the cost of that item. The second parameter is a list containing the names of items to be purchased. The function should calculate the total cost associated with all of the items to be purchased. For example, if the dictionary of item names and costs is: items = {'apple': 12, "banana': 7, 'cherry': 10, 'dragonfruit': 35} and the list of items to be purchased is: selected= ['apple', 'apple', 'cherry', 'dragonfruit', 'cherry'] Then the total cost should be 79. However, you must guard against two types of exceptions that could occur when calculating the total cost: • KeyError: this could occur if an item on the list is not a valid key in the dictionary • TypeError: this could occur if the cost of an item in the dictionary is not a number (in which case, the addition will…For the purposes of this question, if you have a pet of a certain type, that pet needs food, treats, a bed and a house -- but multiple animals of the same kind can share. This function takes what kind of animal or animals you have and returns a shopping list for your pet or pets.Write a function contact_event (visit_a, visit_b) to determine if two visits overlap in time and space, allowing for contact between two people to potentially occur. The parameters of this function are as follows: • visit_a • visit_b each of which is a 7-tuple formatted as described above. The function should return True if a contact could have occurred between two distinct people, and False otherwise. If one visit began at the exact time that the other visit ended, you may assume that a potential contact could not occur (ie, the function should return False). If either of the visits is not valid, the function should return None. Assumptions: • You can assume that the input arguments are syntactically correct given the definitions and assumptions on the previous slides. Here are some example calls to the function: >>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Natalya', 'Foodigm', 2, 9, 30, 9, 45))) True >>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0),…
- i am writing a code in python in order to create an employee management application for a fictional paper company. Each employee is represented by 3 attributes: name, age and position I need to define and use the following functions display_employees(): (this needs a loop inside of the function) allocate_department (returns single list containing information) display_department_employees() (needs a loop inside of this function and uses allocate_department) head_of_department() (uses allocate_department and need to use a loop inside of this function) display_department_employees() (function that displays all info for all department. Thankscomments appreciatedWrite the function truck_adjustment_factor(truck_proportion, terrain_type) that takes the proportion of trucks using the motorway and the terrain type as inputs and returns the adjustment factor that is used for calculating the highway capacity. The adjustment factor is calculated according to the following formula: adju stment factor = tprupurtime x(furtor-1) Where proportion is the proportion of trucks and the factor is the car equivalent factor for the given terrain. You should be calling your car_equivalent_factor function to get the factor - don't reinvent the wheel! For example, for rolling terrain and a truck proportion equal to 0.12: adjustment factor = 1/(1 + 0.12 x (4.0 - 1)) = 0.735 Notes: You should include (and call/use) your car_equivalent_factor function in your answer o In general, you should paste in your whole module so far in each question as later functions will call earlier functions. • You can assume the function will always be called with one of the three valid…
- Write a script that creates and calls a function named fnStudentUnits that calculates the total course units of a student in the StudentCourses table. To do that, this function should accept one parameter for the student ID, and it should return the sum of the course units for the student. The SELECT statement that calls the function should return the StudentID from the StudentCourses table, the CourseNumber and CourseUnits from the Courses table, and the value return by the fnStudentUnits function for that student.Code thisQ2
- Project 2 – Vaccine DistributionIntroductionThis project will require you to write a function that handles matrix data using loops and indexing.You work for a government entity and have been tasked with processing information about vaccinesupply needs. Vaccines are being distributed to people in 5 phases, based on their age, pre-existingconditions, and jobs that place them at risk. Vaccines must be distributed in 2 doses. You haveinformation about the following:- Anonymous information from people in the vaccine site’s region:o The phase that they are eligible for.o Whether they have had 0, 1, or 2 doses of the vaccine.o How many days it has been since the last dose of the vaccine for an individual.- The number of vaccine doses that will be available each day.You have been tasked with determining a distribution plan for determining which individuals will get thevaccine on a given day.ProcedureWrite a function that takes 2 inputs:- A 3xN matrix of data on people in the region. Each…I need the answer as soon as possibleA matrix named mach contains three columns of data concerning the energy output of several machines. The first column contains an ID code for a specific machine, the second column contains the total amount of energy produced by that machine in calories, and the third column contains the amount of time required by that machine to produce the energy listed in column 2 in hours. Write a function to accept as input the matrix mach and return a new matrix named P containing two columns and the same number of rows as mach . The first column should contain the machine ID codes, and the second column should contain the average power generated by each machine in units of watts. The function should utilize for loops to do this.