Chapter 2 : Basics Of Python (Practice Sets)
इस Web Page पर Python के Basics से संबंधित Problems Add की गई है | Basics Python Language की नीव है , इसलिए Python Language के Basics मजबूत होने पर आगे की Programming सिखने मे सरलता होगी | इस Web Page को add करने का उद्देश्य आपको अध्याय में पढ़े गए सभी टॉपिक्स का अभ्यास कराने और आपकी कोडिंग स्किल को बेहतर बनाना है | इन दि गई Problems को Solve करके आप : Python के Basics को और अच्छी तरह समझ पाएंगे , Programs लिखने का confidence बढ़ा पाएंगे , Logic बनाना और Problems solve करना आसान महसूस करेंगे , इसलिए दि गई Problems को खुद से Solve करने की कोशिश करें | इस Web Page पर दि गई Problems Python Basics पर आधारित है , इसलिए Practice Sets को solve करने से पहले Python के Basics जरूर पढ़े |
Problem 1 :
नीचे दिए Code Editor मे एक Python Code लिखे जिसमे , Student के दवारा दिया गया Name एक Student_Name variable मे Store किया जाता हो |
Code Explanation
- Student_Name = input("Enter Your Name") = > Student_Name एक variable है जो input मे Student का Name Store करता है |
Problem 2 :
Teacher School मे किसी Student को Admision देने से पहले Student से संबंधित Informations को प्राप्त करता
है ताकि जरूरत पडने पर Student से Contact किया जा सके |
नीचे दिए गए Code Editor मे ,
- Student से संबंधित Informations को Store करने के लिए 3 Variables create करे |
- s_name , f_name , s_mother name variables के Name हो |
- Create किए गए Variables मे किसी एक Student से संबंधित जानकारी Store करे |
Code Explanation
- s_name = "vijay" = > s_name एक variable है , जिसमे student का Name stored है |
- f_name = "Hell" = > f_name एक variable है , जिसमे Vijay के Father का Name store किया गया है |
- s_mother = "NM" = > s_mother एक variable है , जिसमे Vijay की Mother का Name stored किया गया है |
Problem 3 :
हम Mobile Gallery से ऐसी Images को Ignore कर देते है जो किसी काम की नही होती है |
नीचे दिए गए Code Editor मे ,
1. कोई Five Python Statements लिखे |
2. Multiline या Single line comments का उपयोग कर पहली तीन Statements को Comment
करे |
Code Explanation :
- # = > Last की दो Statements को छोडकर बाकी की Statements को Comment किया गया है |
Problem 4 :
जब घर पर कोई मेहमान आता है तो उसका Welcome किया जाता है |
नीचे दिए गए Code Editor मे एक Python Code लिखे जो ,
- User से input के रूप मे पूछे "what is your name"
- user के name enter करते ही message show हो "Welcome To you"
Code Explanation
- name = input("") = > name नाम का एक Variable Create किया गया है जो input मे मेहमान का name store करता है |
- print(name) = > ये print() function screen पर name variable मे stored name को show करता है |
Problem 5 :
जब कोई Student Teacher से अजीब question का answer पूछता है तब Teacher उस Question के
पूछे जाने के style को ही बदल देता है |
नीचे दिए गए Code Editor मे एक Code लिखे ,
- जिसमे name , class और marks नाम के तीन Variables हो |
- एक Student से संबंधित जानकारी को input के रूप मे name , class और marks variable मे Store करे |
- Screen पर Student Details को ऐसे show करे
Student Name:
Student Class :
Student Marks :
Code Explanation :
- s_name = > s_name नाम का एक variable Create किया गया है जो input मे Student से Student का Name Store करता है |
- s_class = > s_class नाम का एक variable Create किया गया है जो input मे Student से Student की Class Store करता है |
- s_marks = > s_marks एक variable है जो input मे Student के marks store करता है |
- print() = > screen पर values को show करने के लिए Print() function का उपयोग किया गया है |
Problem 6 :
नीचे दिए गए code editor मे एक Python Code लिखा गया है जिसमे variables , comments , input and output का उपयोग किया गया है , लेकिन Code मे कही mistake है जिस कारण error आ रही है आपको error को खतम करके Code को error free करना है |
Code Explanation :
- # = > Code की First Line को Ignore करने के लिए hash(#) का उपयोग किया गया है |
- name = input("") = > name एक variable है जो input मे User का Name Store करता है |
- print(name) = > ये print() function Screen पर name variable Display करता है |
Problem 7 :
School Principal Annual Exam मे student के pass होने के बाद student को दूसरी class मे shift कर देता है
|
नीचे दिए गए Code editor मे एक code दिया गया है जो a नाम के variable के Data type को
Float Data type मे Convert करता है जैसे : int से float लेकिन code मे एक mistake है जिसके कारण error आ
रहा
है | आपको Error को remove करना है और a variable के data type को float मे Convert करना है |
Code Explanation
- a = 10 = > a एक variable है जिसका Data Type integer है |
- b = float(a) = > b एक variable है जिसमे a variable की float value stored है |
- print(b) = > ये print() function screen पर b variable मे stored value को show करता है |
- print(type(b)) = > ये print() function screen पर b variable के Data Type को show करता है |
Problem 8 :
Name swap mixer game मे कोई Player मौजूद Players मे से किसी एक Player के साथ अपने Name को
उस Player के Name के साथ बदलता है और फिर उस player को अपने जैसा Behave करने को कहता है |
नीचे दिए गए Code editor मे एक code लिखे जो ,
- user से input मे 2 integer Numbers ले |
- लिए गए Numbers को a और b नाम के Variables मे store करे |
- a और b variable मे stored Numbers की आपस मे बदली करे यानि a मे stored Number b मे b मे stored Number a मे
Code Explanation
- a = int(input("")) = > a नाम का एक variable create किया गया है जो input मे एक Integer Number Store करता है |
- b = int(input("")) = > b नाम का एक variable create किया गया है जो input मे Second Number Store करता है |
- temp = a = > temp एक variable है जिसकी Value a Variable के बराबर है |
- a = b = > a एक variable है जिसकी Value b Variable के बराबर है |
- b = temp = > b एक variable है जिसकी Value temp Variable के बराबर है |
- print() = > ये Print() function a और b variable मे stored value को show करता है |
Problem 9 :
नीचे दिए गए code editor मे एक code दिया गया है जो बिना किसी Temporary variable का उपयोग किए बिना x और y variable को आपस मे swap करता है , लेकिन code मे एक Mistake है जिसके कारण Code को run करने पर error आ रही है आपको Code मे की गई Mistake को remove करके x और y दोनों variables को swap करना है |
Code Explanation
- a = 5 = > a एक Variable है जिसमे 5 Stored है |
- b = 9 = > b नाम का एक variable Create किया गया है जिसमे 9 Stored है |
- a, b = b, a = > a variable की value b और b variable की value a हो जाती है |
- print("a =", a) = > ये print() function screen पर a variable को display करता है |
- print("b =", b) = > ये print() function screen पर b variable को display करता है |
Problem 10 :
किसी company मे job देने से पहले ही Company Manager Company के Rules को
बता देते है ताकि job पाने वाले को बाद मे कोई Problem ना हो ||
नीचे दिए गए code editor मे एक Code लिखे ,
- जिसमे Top मे Code का Purpose लिखा हो |
- Employee से input मे Question पूछा जाए "do you agree with"
- Employee के Answer देते ही "Thank You" Message show हो |
Code Explanation
- """ """ = > Triple Double Quotes (""" """) मे Code के Purpose लिखे गए है |
- ans = input("") = > ans एक variable है जो input मे Employee से उसका answer store करता है |
- print() = > ये Print() function Screen पर Thank You Message show करता है |
You have completed This Chapter ! 🎉
Now you can choose any one of the following options to test your knowledge :
Help Center
Users and we all help you together .