Page 259 - CITS - CSA - TP (Volume 2) - Hindi
P. 259
कं ूटर सॉ वेयर ए ीके शन - CITS
अ ास 126: पुनरावृि करने वाले कोड से ट का िनमा ण और िव ेषण कर (Construct and analyze
code segments that perform iteration)
उ े
इस अ ास के अंत म आप यह कर सक गे
• पुनरावृि करने वाले कोड से ट का िनमा ण और िव ेषण करने के िलए पायथन ो ाम डेवलप करना।
आव कताएं (Requirements)
उपकरण/साम ी (Tools/Materials)
• िवंडोज OS वाला PC/लैपटॉप
• पायथन का नवीनतम वज न
ि या (Procedure)
पायथन While लूप
टा 1: 1 से n तक की सं ाएँ ि करने के िलए पायथन ो ाम
कोड:
limit=int(input(“Enter the Limit: “))
# Initialize the variable i with the value 1
i = 1
# The loop will continue as long as i is less than or equal to limit
whilei<= limit:
# Print the current value of i, followed by a space instead of a newline
print(i, end=’ ‘)
# Increment the value of i by 1 in each iteration
i += 1
ीकरण:
• i को 1 से आरंभ िकया जाता है।
• while लूप तब तक जारी रहता है जब तक शत i<= limit स है।
• लूप के अंदर, print(i, end=’ ‘) अगली लाइन पर जाए िबना, i के वत मान मान को एक ेस के बाद ि ंट करता है।
• i += 1 लूप के ेक पुनरावृि म i के मान को 1 से बढ़ाता है।
आउटपुट :
245

