Page 250 - CITS - CSA - TP (Volume 2) - Hindi
P. 250
कं ूटर सॉ वेयर ए ीके शन - CITS
अ ास 124: ऑपरेटर वरीयता के आधार पर िन ादन का म िनधा रत कर (Determine the
sequence of execution based on operator precedence)
उ े
इस अ ास के अंत म आप यह कर सक गे
• ऑपरेटर वरीयता के आधार पर िन ादन के अनु म को िनधा रत करने के िलए पायथन ो ाम डेवलप कर
आव कताएं (Requirements)
उपकरण/साम ी (Tools/Materials)
• िवंडोज OS वाला PC/लैपटॉप
• पायथन का नवीनतम वज न
ि या (Procedure)
टा 1: अंकगिणतीय ऑपरेशन
कोड :
# Program to demonstrate arithmetic operations based on precedence
num1 = float(input(“Enter the first number: “))
num2 = float(input(“Enter the second number: “))
result = num1 * (num2 + 3) / 2
print(“Result:”, result)
आउटपुट:
टा 2: तुलना क और लॉिजकल ऑपरेटर
कोड:
# Program to demonstrate comparison and logical operators based on precedence
x = int(input(“Enter a number: “))
y = int(input(“Enter another number: “))
result = x > 0 and (y % 2 == 0 or y > 10)
print(“Result:”, result)
आउटपुट:
236

