-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek_2.txt
89 lines (89 loc) · 4.92 KB
/
week_2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
resource url?
QUESTION ----------------
For example:
------------------ANSWER
a=float(input())
i=4/100
a+=i*a
print("Balance as of end of Year 1: $%.2f."%a)
a+=i*a
print("Balance as of end of Year 2: $%.2f."%a)
a+=i*a
print("Balance as of end of Year 3: $%.2f."%a)
------------------------------
QUESTION ----------------
Note:
------------------ANSWER
age=int(input())
w=int(input())
print(age>=18 and w>40)
------------------------------
QUESTION ----------------
Mr.Ram has been given a problem kindly help him to solve it. The input of the program is either 0 or 1. IF 0 is the input he should display "C" if 1 is the input it should display "D".There is a constraint that Mr. Ram should use either logical operators or arithmetic operators to solve the problem, not anything else.
------------------ANSWER
n=int(input())
print(n and 'D' or 'C')
------------------------------
QUESTION ----------------
The program that you create for this exercise will begin by reading the cost of a meal ordered at a restaurant from the user. Then your program will compute the tax and tip for the meal. Use your local tax rate (5 percent) when computing the amount of tax owing. Compute the tip as 18 percent of the meal amount (without the tax). The output from your program should include the tax amount, the tip amount, and the grand total for the meal including both the tax and the tip. Format the output so that all of the values are displayed using two decimal places.
------------------ANSWER
n=int(input())
t=0.05*n
p=0.18*n
print("The tax is %.2f"%(t),"and the tip is %.2f,"%(p),"making the total %.2f"%(n+t+p))
------------------------------
QUESTION ----------------
In London, every year during Dasara there will be a very grand doll show. People try to invent new dolls of different varieties. The best-sold doll's creator will be awarded with a cash prize. So people broke their heads to create dolls innovatively. Knowing this competition, Mr.Lokpaul tried to create a doll that sings only when an even number is pressed and the number should not be zero and greater than 100. IF Lokpaul wins print true, otherwise false.Sample Input10Sample OutputTrueExplanation:Since 10 is an even number and a number between 0 and 100, True is printed
------------------ANSWER
n=int(input())
print((n%2==0) and (0<n<100))
------------------------------
QUESTION ----------------
In the 1800s, the battle of Troy was led by Hercules. He was a superstitious person. He believed that his crew can win the battle only if the total count of the weapons in hand is in multiple of 3 and the soldiers are in an even number of count. Given the total number of weapons and the soldier's count, Find whether the battle can be won or not according to Hercules's belief. If the battle can be won print True otherwise print False.
------------------ANSWER
w=int(input())
s=int(input())
print((w%3==0)and (s%2==0))
------------------------------
QUESTION ----------------
Write a python program that takes a integer between 0 and 15 as input and displays the number of '1' s in its binary form.(Hint:use python bitwise operator.
------------------ANSWER
n=int(input())
a1=n&1
n=n>>1
a2=n&1
n=n>>1
a3=n&1
n=n>>1
a4=n&1
print(a1+a2+a3+a4)
------------------------------
QUESTION ----------------
Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after the party. He went to a shop to buy a packet of chocolates. At the chocolate shop, 4 packets are there with different numbers of chocolates. He wants to buy such a packet which contains a number of chocolates, which can be distributed equally among all of his friends. Help Mr. X to buy such a packet. Input Given: N-No of friendsP1,P2,P3 AND P4-No of chocolatesOUTPUT: "True" if he can buy that packet and "False" if he can't buy that packet.SAMPLE INPUT AND OUTPUT:52512 10 9OUTPUTTrue False True False
------------------ANSWER
n=int(input())
p1=int(input())
p2=int(input())
p3=int(input())
p4=int(input())
print(p1%n==0,p2%n==0,p3%n==0,p4%n==0)
------------------------------
QUESTION ----------------
Write a program that returns the last digit of
the given number. Last digit is being referred to the least significant digit i.e.
the digit in the ones (units) place in the given number.
------------------ANSWER
n=int(input())
print(abs(n)%10)
------------------------------
QUESTION ----------------
An online retailer
sells two products: widgets and gizmos. Each widget weighs 75 grams.
Each gizmo weighs 112 grams. Write a program that reads the number
of widgets and the number of gizmos from the user. Then your program
should compute and display the total weight of the parts.Sample Input:1020Sample Output:The total weight of all these widgets and gizmos is 2990 grams.
------------------ANSWER
w=int(input())
g=int(input())
print("The total weight of all these widgets and gizmos is",((w*75)+(g*112)),"grams.")
------------------------------