जब दो संख्याओं को पढ़ना और भागफल और शेष को विभाजित करने पर प्रिंट करना आवश्यक हो, तो '//' और '%' ऑपरेटरों का उपयोग किया जा सकता है।
नीचे उसी का एक प्रदर्शन है -
उदाहरण
first_num = int(input("Enter the first number..."))
second_num = int(input("Enter the second number..."))
print("The first number is ")
print(first_num)
print("The second number is ")
print(second_num)
quotient_val = first_num//second_num
remainder_val = first_num%second_num
print("The quotient is :")
print(quotient_val)
print("The remainder is :")
print(remainder_val) आउटपुट
Enter the first number...44 Enter the second number...56 The first number is 44 The second number is 56 The quotient is : 0 The remainder is : 44
स्पष्टीकरण
-
पहले और दूसरे नंबर को उपयोगकर्ता से इनपुट के रूप में लिया जाता है।
-
वे कंसोल पर प्रदर्शित होते हैं।
-
भागफल खोजने के लिए, '//' ऑपरेटर का उपयोग किया जाता है।
-
शेष को खोजने के लिए, '%' ऑपरेटर का उपयोग किया जाता है।
-
ऑपरेशंस आउटपुट क्रमशः दो चरों को सौंपा गया है।
-
यह कंसोल पर आउटपुट के रूप में प्रदर्शित होता है।