-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_operators.py
More file actions
87 lines (74 loc) · 2.93 KB
/
Copy pathpython_operators.py
File metadata and controls
87 lines (74 loc) · 2.93 KB
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
print('''============================
Section: A
============================''')
print("---------Que1: Precedence check-------")
print('''x = 5 + 3 * 2 ** 2
print(x)''') #we dont have to run this solve it in your mind.
print("Output: 17")
print("\n")
print("---------Que2: Associativity check-------")
print('''y=2**3**2
print(y)''')
print("Output: 512")
print("\n")
print("---------Que3: Associativity check-------")
print('''z = 20 - 5 - 3
print(z)''')
print("Output: 12")
print("\n")
print('''===========================
Section: B
============================''')
print("----------Question: 1---------------")
print("print(10 > 5 and 5 != 5 or 4 == 4)")
print("Output: True")
print("\n")
print("-----------Question: 2---------------")
print('''If score=85, then which option will be return True?
a) score > 90 and score < 100
b) not (score == 85)
c) score >= 80 or score == 100
d) score < 80 and score > 70''')
print("Ans: option C will be the correct answer. ")
print("\n")
print("------------Question: 3---------------")
print('''Precedence order of the + operator is less than the precedence order of the * operator but if any question these operators are come together and we have to operate/solve the + operator first then which symbol will be taken in the consideration?
a) **
b) %
c) ()
d) //''')
print("Ans: option c will be the correct answer.")
print("\n")
print('''===========================
Section: C
============================''')
print("------------Challenge 1: The E-Commerce Checkout Logic------------")
cart_total = 0
# Task 1: User ne 200 ki T-shirt aur 350 ki Jeans add ki (+= ka use karein)
# Task 2: User ne 50 ka discount code lagaya (-= ka use karein)
# Task 3: Comparison (>=) ka use karke check karein ki kya cart_total 500 ya usse zyada hai.
# Result ko 'free_delivery' naam ke variable (Boolean) mein save karein aur print karein.
print("-----------------------------Output:1--------------------------------")# Aapka code yahan likhein:
cart_total+=200+350
cart_total-=50
free_delivery=print(cart_total>=500)
print("\n")
print("------------Challenge 2: The Smart Login System------------")
user_age = 20
is_pro_member = True
# Task: Ek 'can_login' variable banayein jo True tabhi ho jab user_age 18+ ho AUR is_pro_member True ho.
# Print karein: "Login Status: True" ya "Login Status: False"
print("-----------------------------Output:2-------------------------")# Aapka code yahan likhein:
can_login= user_age>18 and is_pro_member==True
print("Login Status:",can_login)
print("\n")
print("-----------------Challenge 3: Average Formula Fix------------")
math_marks = 80
sci_marks = 90
eng_marks = 70
# Bug: Division (/) ki precedence Addition (+) se zyada hoti hai,
# isliye ye sirf eng_marks ko 3 se divide kar raha hai.
# wrong_average = math_marks + sci_marks + eng_marks / 3
print("---------------------------Output:3---------------------------")
correct_average= (math_marks+sci_marks+eng_marks)/3
print(correct_average)