Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

How do I construct a loop for my input statements? Input question is, "What type of coffee would you like today?" If user selects a coffee, they pass, but if they fail, they must retry.


order = input("\n" + first_name.capitalize() + "," " " + "What type of Coffee would you like today?\n\n" +
              "\n".join(["Expresso", "Latte", "Cappuccino", "Mocha", "Frappuccino"]) + "\n\n")

order = order.replace("and a", "")
order = order.replace("and", "")
order = order.replace(",", "")
order = order.lower().split()

union = " and a " if len(order) > 1 else ""

plural = "" if len(order) > 1 else ""

order = input("\nYou have selected a" + " " + ", ".join(order[:-1]).title() + union + plural + order[-1].title()
              + "!" + " " + "\n\nIs this correct?\n\n")













A hospital wants to store a record regarding its patients. The information to store include

  • Name of the patient
  • Age of the patient
  • Date of Birth of Patient (yyyy/mm/dd)
  • Disease
  • Date of Admission
  • Date of discharge

Create a class called Patient to store the above information. Date of Birth and Disease of a patient should be private data attributes. Create public methods which take all above information as input from user and then display / output all the information.


Suppose you went to a coffee shop and you want to drink some coffee. You


decided to drink n cup of coffee, where n is an integer value greater than


0. Now you have to pay m taka for the first cup of coffee, 2m taka for the


second cup, 3m takas for the third cup, and so on. In other words, you have


to pay i*m taka for the i-th cup of coffee.



Now you have k taka in your pocket. How many takas do you need to borrow


from your friend to buy n cup of coffee?



The first input in the sample input contains the cost of the first cup of


coffee which can be denoted as m. The second input is the number of coffees


you want to drink, n. The third input is k, the initial amount of taka you


have. You have to calculate how much money you have to borrow from your


friend. If you have more or equal amount of money that is needed than print


0.




Problem statement: Bike drop distance optimisation


Using Python, please optimise for the following: In the df1, you have the bikes and its pickup locations. In df2, you have the drop locations. You have to assign a drop location from df2 to every bike present in df1 in such a way that it meets all the below conditions.




Df1: Bike pickup locations (excel attached)



Df2: Bike drop locations (excel attached)



Constraints:



1.



Hex with avg daily sessions/supply Minimum no. of bikes should be drop Maximum no. of bikes can be drop



>120 6 8



[100 to 120) 2 4



[50 to 100) 2 3



[30 to 50) 1 2



[20 to 30) 1 1



[10 to 20) 0 1



<10 0 0



2. You have to always aim for the maximum number of bikes to be dropped in the respective destination hex but if the drop distance is more than 4km you will have to assign a different drop hex to it.




Create a Python script which will accept a positive integer and will determine the input number if PERFECT, ABUNDANT, DEFICIENT.


PERFECT - if the sum of the divisors of the number except the number itself is equal to the number.


E.g. 6= 1, 2, 3, 6 1+2+3=6


ABUNDANT - if the sum of the divisors of the number except the number itself is greater than the number.


E.g. 12= 1, 2, 3, 4, 6, 12 1+2+3+4+6 = 16


DEFICIENT- if the sum of the divisors of the number except the number itself is less than the number.


E.g. 10= 1, 2, 5, 10 1+2+5=8


Sample Output:


Input a Positive Integer : 20


20 is ABUNDANT!



Please help me, thank you.

CS curriculum consists n courses, all mandatory. prerequisite graph G node each course, edge course v course w if and only if v prerequisite w. directly graph representation, computes minimum number semesters necessary complete curriculum student can take number courses one semester. running time your algorithm should linear. Input Format: input text file which describes prerequisite graph G. prerequisite graph G DAG. first line file specifies n & m, next m lines specify m edges graph, one line per edge. edge described end points. number vertices n, assume vertices graph numbered (0,1,..n-1). Output Format: Print minimum number of semesters required complete curriculum, given prerequisite graph, minimum number semesters will fixed number, there may be more one way taking courses each semesters. Sample Input ( graph shown right): 9 8 0 3 1 3 2 4 3 5 4 5 5 6 6 7 5 8 Sample Output Minimum number semesters: 5 Sem 1: 0, 1, 2 Sem 2: 3, 4 Sem 3: 5 Sem 4: 6, 8 Sem 5: 7


Given a directed graph, write a program to print all the strongly connected components of the graph. The runtime of your algorithm should be linear. Input Format: The input is a text file which describes an directed graph. The first line of the file specifies n & m, the number of vertices and number of edges in the graph respectively. The next m lines specify the m edges of the graph, one line per edge. An edge is described by its end points. If the number of vertices is n, assume that the vertices of the graph are numbered (0,1,..n-1). Output Format: Print the list of vertices in each strongly connected component, one line per component. (The order in which the SCCs are printed, and the relative order of the vertices within a given SCC does not matter.) Sample Input (for the graph shown on the right): 11 15 0 1 1 2 2 0 1 3 3 5 5 4 4 3 5 7 7 6 6 7 5 8 7 8 8 9 9 10 10 8 Sample Output : SCC 1: 8, 9, 10 SCC 2: 6, 7 SCC 3: 3, 4, 5 SCC 4: 0, 1, 2



Make classes to manage a cinema.

  • Use just strings and ints to keep things clear.
  • No need for get() and set()
  • Test your code with two hard-coded (no input()) objects of each class
  • A cinema has:
  • Movie:attrs: name, rating (int 1..5), length (two ints: hours and minutes)
  • methods: printM()
  • Snack:attrs: name, price, #calories
  • methods: printS()
  • Employee:attrs: name, dateHired
  • methods: printE()


  • script module that will let the user to enter his/her password and username, if username is "X" or "x", program will exit. if username and password are correct, a welcome message and the menu will be displayed . Otherwise, prompt the user for username and password again. program must perform the view, add or delete friend function depend on user input.
  • a myLogin module that will retrieve the information of the user given username and password.
  • a manageData module that will allow the retrieval, adding and deleting of friend(s).


The content of each file follow below format:


username1;[username2];[username3];

Input


1. data

Output


Enter·username:·prettyME
Enter·password:·1234
Welcome,·Rhea·Tortor!

1·-·View·Friend
2·-·Add·friend
3·-·Delete·Friend
X·-·Exit

Enter·your·choice:·X
Successfully·LogOut.
Enter·username:·X

Pyramids Frequency

These are N pyramids in a line.You are given their heights as space-separated integers.Write a program to print the heights of the pyramids in increasing order along with their frequency.


Input

The first line of input contains space-separated integers.


Output

Each line of output should contain the height of the pyramid and its frequency in the ascending order of the pyramid's height.


Explanation

In the example, The given pyramid heights are 1,5,1,2,5,6.

The frequency of each unique pyramid height is

1 2

2 1

5 2

6 1


Sample Input1

1 5 1 2 5 6

Sample Output1

1 2

2 1

5 2

6 1



LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS