├── Aug - Dec 2021 JOC Course ├── Exam Pattern.md ├── Online Programming Test Solution │ ├── Evening Session Solution.py │ ├── Morning Session Solution.py │ └── README.md ├── README.md ├── Week 0 │ └── README.md ├── Week 1 │ └── README.md ├── Week 10 │ ├── README.md │ ├── Week 10 Programming Assignment 1.py │ └── Week 10 Programming Assignment 2.py ├── Week 11 │ ├── README.md │ ├── Week 11 Programming Assignment 1.py │ ├── Week 11 Programming Assignment 2.py │ └── Week 11 Programming Assignment 3.py ├── Week 12 │ ├── README.md │ ├── Week 12 Programming Assignment 1.py │ ├── Week 12 Programming Assignment 2.py │ └── Week 12 Programming Assignment 3.py ├── Week 2 │ ├── README.md │ ├── Week 2 Programming Assignment 1.py │ ├── Week 2 Programming Assignment 2.py │ └── Week 2 Programming Assignment 3.py ├── Week 3 │ ├── README.md │ ├── Week 3 Programming Assignment 1.py │ ├── Week 3 Programming Assignment 2.py │ └── Week 3 Programming Assignment 3.py ├── Week 4 │ ├── README.md │ ├── Week 4 Programming Assignment 1.py │ ├── Week 4 Programming Assignment 2.py │ └── Week 4 Programming Assignment 3.py ├── Week 5 │ ├── New Week 5 Programming Assignment 2.py │ ├── README.md │ ├── Week 5 Programming Assignment 1.py │ ├── Week 5 Programming Assignment 2.py │ └── Week 5 Programming Assignment 3.py ├── Week 6 │ ├── README.md │ ├── Week 6 Programming Assignment 1.py │ ├── Week 6 Programming Assignment 2.py │ └── Week 6 Programming Assignment 3.py ├── Week 7 │ ├── README.md │ ├── Week 7 Programming Assignment 1.py │ ├── Week 7 Programming Assignment 2.py │ └── Week 7 Programming Assignment 3.py ├── Week 8 │ ├── README.md │ ├── Week 8 Programming Assignment 1.py │ ├── Week 8 Programming Assignment 2.py │ └── Week 8 Programming Assignment 3.py └── Week 9 │ ├── README.md │ ├── Week 9 Programming Assignment 1.py │ └── Week 9 Programming Assignment 2.py ├── Code Of Conduct.md ├── Exam Pattern.md ├── JOC previous years weekly quizes ├── JOC 2018.pdf ├── JOC Jan-Apr 2021.pdf ├── JOC Jan-Aug 2020.pdf ├── JOC Sep-Dec 2020.pdf └── README.md ├── Jan - Apr 2022 JOC Course ├── README.md ├── Week 0 │ └── README.md ├── Week 1 │ └── README.md ├── Week 10 │ ├── README.md │ ├── Week 10 Programming Assignment 1.py │ ├── Week 10 Programming Assignment 2.py │ └── Week 10 Programming Assignment 3.py ├── Week 11 │ ├── README.md │ ├── Week 11 Programming Assignment 1.py │ ├── Week 11 Programming Assignment 2.py │ └── Week 11 Programming Assignment 3.py ├── Week 12 │ ├── README.md │ ├── Week 12 Programming Assignment 1.py │ ├── Week 12 Programming Assignment 2.py │ └── Week 12 Programming Assignment 3.py ├── Week 2 │ ├── README.md │ ├── Week 2 Programming Assignment 1.py │ ├── Week 2 Programming Assignment 2.py │ └── Week 2 Programming Assignment 3.py ├── Week 3 │ ├── README.md │ ├── Week 3 Programming Assignment 1.py │ ├── Week 3 Programming Assignment 2.py │ └── Week 3 Programming Assignment 3.py ├── Week 4 │ ├── README.md │ ├── Week 4 Programming Assignment 1.py │ ├── Week 4 Programming Assignment 2.py │ └── Week 4 Programming Assignment 3.py ├── Week 5 │ ├── README.md │ ├── Week 5 Programming Assignment 1.py │ ├── Week 5 Programming Assignment 2.py │ └── Week 5 Programming Assignment 3.py ├── Week 6 │ ├── README.md │ ├── Week 6 Programming Assignment 1.py │ ├── Week 6 Programming Assignment 2.py │ └── Week 6 Programming Assignment 3.py ├── Week 7 │ ├── README.md │ ├── Week 7 Programming Assignment 1.py │ ├── Week 7 Programming Assignment 2.py │ └── Week 7 Programming Assignment 3.py ├── Week 8 │ ├── README.md │ ├── Week 8 Programming Assignment 1.py │ ├── Week 8 Programming Assignment 2.py │ └── Week 8 Programming Assignment 3.py └── Week 9 │ ├── README.md │ ├── Week 9 Programming Assignment 1.py │ ├── Week 9 Programming Assignment 2.py │ └── Week 9 Programming Assignment 3.py ├── LICENSE ├── NPTEL-Course-Lecture Programmes ├── Anagrams.py ├── AnalysisOfGraph.gexf ├── AreaCalculate.py ├── BinarySearch.py ├── BrowserAutoWatsapp.py ├── BubbleSort.py ├── Calender.py ├── CollatzConjecture.py ├── Colorpicker.py ├── Conv_factor.py ├── DataTime.py ├── DateTime.py ├── Dictionary.py ├── F.L.A.M.E.S.py ├── FibonacciRecur.py ├── FileOperations.py ├── Formatting.py ├── Gambling.py ├── Gmplot.py ├── Graphs.py ├── GraphsEdgeNode.py ├── Hangman.py ├── HowDoesGoogleWork.py ├── ImageCompressing.py ├── ImageTransposing.py ├── ImgEnhancing.py ├── India.jpg ├── KmaxKmin.py ├── MagicSquare.py ├── Making-an-Img.py ├── Myhouse.html ├── Numpy.py ├── NumpyMatrixOperations.py ├── Pager.ipynb ├── Players.py ├── Plot-img.png ├── Practice.py ├── Practice2.py ├── RGB-Format.png ├── RandomWalkOnGraph.py ├── RockPaperScissors.py ├── SameLetterCards.py ├── Snakes&Ladder.py ├── Sorted_KeyWord.py ├── Testing.txt ├── Testing_op.txt ├── TicTacToe.py ├── Timezones.py ├── Tuple.py ├── lena.bmp ├── monteHall.py ├── page_rank.txt ├── snakes.jpg ├── substitutionCipher.py ├── temp.py └── template.py ├── Online Programming Test Solution ├── README.md ├── evening session solution.py ├── exam_1.py └── solutions.py ├── README.md ├── Week0 └── README.md ├── Week1 └── README.md ├── Week10 ├── README.md ├── week 10 programming assignment 1.py ├── week 10 programming assignment 2.py └── week 10 programming assignment 3.py ├── Week11 ├── README.md ├── Week 11 Programming Assignment 1.py ├── Week 11 Programming Assignment 2.py └── Week 11 Programming Assignment 3.py ├── Week12 ├── README.md ├── Week 12 programming assignment 1.py ├── Week 12 programming assignment 2.py └── Week 12 programming assignment 3.py ├── Week2 ├── README.md ├── Week 2 programming assignment 1.py ├── Week 2 programming assignment 2.py └── Week 2 programming assignment 3.py ├── Week3 ├── New Week 3 Programming Assignment 3.py ├── README.md ├── Week 3 Programming Assignment 1.py ├── Week 3 Programming Assignment 2.py └── Week 3 Programming Assignment 3.py ├── Week4 ├── README.md ├── Week 4 Programming Assignment 1.py ├── Week 4 Programming Assignment 2.py └── Week 4 Programming Assignment 3.py ├── Week5 ├── README.md ├── Week 5 Programming Assignment 1.py ├── Week 5 Programming Assignment 2.py └── Week 5 Programming Assignment 3.py ├── Week6 ├── README.md ├── Weeek 6 Programming Assignment 1.py ├── Weeek 6 Programming Assignment 2.py └── Weeek 6 Programming Assignment 3.py ├── Week7 ├── README.md ├── Week 7 Programming Assignment 1.py ├── Week 7 Programming Assignment 2.py └── Week 7 Programming Assignment 3.py ├── Week8 ├── README.md ├── Week 8 Programming Assignment 1.py ├── Week 8 Programming Assignment 2.py └── Week 8 Programming Assignment 3.py └── Week9 ├── README.md ├── Week 9 Programming Assignment 2.py ├── Week 9 Programming Assignment 3.py └── Week 9 Programming Assignment1.py /Aug - Dec 2021 JOC Course/Exam Pattern.md: -------------------------------------------------------------------------------- 1 | # Exam Pattern of JOC Course🔥 2 | 3 | 🔶 In Proctored / Center Based Examaination you will be getting only **Multiple Choice Question (MCQ)** with total 50 questions and The total duration of the examination is 180 minutes⏰. 4 | 5 | 🔶 The questions will be divided into 3 sections i,e, A, B, C respectively where, 6 | 7 | - **Section A :** contains 10 questions and 2 marks for each. 8 | 9 | - **Section B :** contains 15 questions and 2 marks for each. 10 | 11 | - **Section C :** contains 25 questions and 2 marks for each. 12 | 13 | ❗❗ Therefore, **Total Marks = 100** and for passing exam you have to score at least **40 marks** out of **100** or at least you have to correct **20 questions** for passing the examination.❗❗ 14 | 15 | ## 📌 How to prepare for the Exam❓🤷‍♂️ 16 | 17 | 1️⃣ You should solve all the **weekly quizzes** of your session as well as previous sessions and remember do not try to just muggings the questions apart from this try to understand concepts behind each and every questions. For previous sessions weekly quizzes **[CLICK HERE](https://github.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/tree/main/JOC%20previous%20years%20weekly%20quizes)** 18 | 19 | 2️⃣ Here is one trivia for all of you if you solved all the weekly quizzes then there is high probability that some questions will directly come from weekly quizzes that means **100% Copy Paste.** 20 | 21 | 3️⃣ There is also high chances of some questions that will directly come from weekly quizzes but, in that questions you will be getting different values or data. 22 | 23 | **⚠(Note : In my opinion seeing video lectures are not that important because in exam you'll be getting hardly 1 or 2 questions from the lectures.)⚠** 24 | 25 | ## 📌 Important topics for the exam🤔 26 | 27 | - String, List, Dictionary, Tuple, Set 28 | 29 | - Conditional Statements (For Loop & While Loop) 30 | 31 | - Random & Numpy Library 32 | 33 | - Basic Scratch & Turtle Problem (Only 2 or 3) 34 | 35 | - Graph (Finding degree of separartion & Finding number of edges questions) 36 | 37 | ## 📌 Things that are allowed and not allowed on the exam center🙄 38 | 39 | | **Permitted** | **Not Permitted** | 40 | |:---------------:|:------------------:| 41 | | You may bring vehicle keys inside the exam hall, You should bring your own pen/pencil; it would not be given at the examination centre | Analog/Smart/digital/programmable watches, wallets, mobile phones, bluetooth devices, microphones,pagers, health bands or any other electronic gadgets, any printed/blank/handwritten paper, log tables, writing pads, scales,geometry/pencil-boxes, pouches, calculators, pen drives, electronic pens, handbags, goggles | 42 | 43 | 44 | ## 📌 If still you have any doubt you can reach out to me or just open an issue here : 45 |

46 | kishan_rajput23 47 | https://www.linkedin.com/in/kishan-kumar-rai-23112000 48 | https://www.facebook.com/kishan.kumarrai.79 49 | kishan_rajput23 50 |

51 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Online Programming Test Solution/Evening Session Solution.py: -------------------------------------------------------------------------------- 1 | s=input() 2 | j=0 3 | for i in range(len(s)): 4 | if j>=len(s)-1: 5 | break 6 | n=s[j] 7 | while s[j]==s[j+1]: 8 | n = n+s[j] 9 | j+=1 10 | if j >= len(s)-1: 11 | break 12 | j+=1 13 | print("({},{})".format(len(n), n[0]),end="") 14 | if(s[len(s)-1]!=s[len(s)-2]): 15 | print("(1,{})".format(s[len(s)-1]),end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Online Programming Test Solution/Morning Session Solution.py: -------------------------------------------------------------------------------- 1 | import textwrap 2 | s = input() 3 | w = int(input()) 4 | 5 | 6 | wrapper = textwrap.TextWrapper(width=w) 7 | 8 | word_list = wrapper.wrap(text=s) 9 | 10 | # Print each line. 11 | for element in word_list: 12 | print(element) -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Online Programming Test Solution/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 0/README.md: -------------------------------------------------------------------------------- 1 | # Week 0 Quiz 💡 2 | 3 | **1. What is the circumference of a circle inscribed inside a rectangle with a length of 8 meters and breadth of 4 meters ?** 4 | - 12.57 ✅ 5 | - 25.132 6 | - 6.28 7 | - 50.27 8 | 9 | **2. What is the sum of the first 27 odd numbers?** 10 | - 8109 11 | - 729 ✅ 12 | - 27 13 | - 108 14 | 15 | **3. What is the Least Common Multiple of 12 and 8?** 16 | - 2 17 | - 12 18 | - 8 19 | - 24 ✅ 20 | 21 | **4. If the length of the square is thrice its original length, its perimeter will be 120 meters. What is the original length of the square?** 22 | - 30 23 | - 10 ✅ 24 | - 40 25 | - 20 26 | 27 | **5. In a class, there are 80 students who have taken science which is 40% of the total strength. 20% of students have taken maths and the remaining students have taken english. How many students have taken english?** 28 | - 80 ✅ 29 | - 400 30 | - 200 31 | - 40 32 | 33 | **6. Find the next number of the sequence 1, 5, 13, 25, _______** 34 | - 29 35 | - 41 ✅ 36 | - 33 37 | - 37 38 | 39 | **7. If the perimeter of the square is 100, what is the area of the square?** 40 | - 10000 41 | - 2500 42 | - 625 ✅ 43 | - 1000 44 | 45 | **8. If the circumference of the circle is 31.4, what is the area of the circle?** 46 | - 78.5 ✅ 47 | - 314 48 | - 15.6 49 | - 15.6 50 | 51 | **9. What is the golden value ratio?** 52 | - 1.618 ✅ 53 | - 1.168 54 | - 1.861 55 | - None of the above. 56 | 57 | **10. Choose the odd one out. 1, 2, 3, 5** 58 | - 1 ✅ 59 | - 5 60 | - 3 61 | - None of the above 62 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 1/README.md: -------------------------------------------------------------------------------- 1 | # Week 1 Quiz 💡 2 | 3 | **1. What is the value of var after double clicking on the below block of code in scratch?** 4 | 5 | 6 | 7 | - 7.5 8 | - 5 ✅ 9 | - 3 10 | - 50 11 | 12 | **2. Choose the odd one out. wait, repeat, forever, move** 13 | 14 | - wait 15 | - repeat 16 | - forever 17 | - move ✅ 18 | 19 | **3. How far will the sprite be from the initial position after executing this block of code?** 20 | 21 | 22 | 23 | - 141.42 steps ✅ 24 | - 100 steps 25 | - 10 steps 26 | - 200 steps 27 | 28 | **4. What is the name of the command used to reshow the hidden sprite?** 29 | 30 | - reappear 31 | - show ✅ 32 | - undo hide 33 | - visible 34 | 35 | **5. The command used to make the sprite rotate by a certain degree is ?** 36 | 37 | - turn ✅ 38 | - rotate 39 | - revolve 40 | - bend 41 | 42 | **6. The command used to delay the sprite by a few seconds is ________** 43 | 44 | - wait ✅ 45 | - hold 46 | - stop 47 | - None of the above 48 | 49 | **7. What will the sprite recite when the below block of code is executed?** 50 | 51 | 52 | 53 | - All even numbers from 1 to 100 54 | - All even numbers from 1 to 200 55 | - All odd numbers from 1 to 100 56 | - All odd numbers from 1 to 200 ✅ 57 | 58 | **8. Which of the following does not belong to the motion command ?** 59 | 60 | - move 61 | - turn 62 | - glide 63 | - None of the above ✅ 64 | 65 | **9. What is the command to increase the size of the sprite?** 66 | 67 | - increase size 68 | - change size by ✅ 69 | - expand 70 | - zoom in 71 | 72 | **10. When will the sprite stop moving when this block of code is executed ?** 73 | 74 | 75 | 76 | - Never ✅ 77 | - It will stop after a while 78 | - It will stop after 100 rounds 79 | - None of the above 80 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 10/README.md: -------------------------------------------------------------------------------- 1 | # Week 10 Quiz 💡 2 | 3 | **1. Classify the following types of compressed image files as lossy or lossless compression type.** 4 | 5 | (1) PNG\ 6 | (2) JPEG 7 | 8 | - (1) Lossless ✅\ 9 | (2) Lossey 10 | - (1) Lossey\ 11 | (2) Lossless 12 | - (1) Lossless\ 13 | (2) Lossless 14 | - (1) Lossey\ 15 | (2) Lossey 16 | 17 | **2. Compression can be used to reduce or change file size and which of these following attributes?** 18 | 19 | - File type 20 | - Resolution 21 | - Bit depth 22 | - All of the above ✅ 23 | 24 | **3. NumPy is a python library written partially in python and most parts that require fast computation are written in C or C++. State whether the following statement is true or false.** 25 | 26 | - True ✅ 27 | - False 28 | 29 | **4. What is the output of the following program ?** 30 | 31 | 32 | 33 | - 5 ✅ 34 | - 2 35 | - 2 36 | - Error message 37 | 38 | **5. What is the output of the following program?** 39 | 40 | 41 | 42 | - eo ae a oo a ✅ 43 | - oe ae a oo a 44 | - ae ae a oo a 45 | - None of the above 46 | 47 | **6. What is the output of the following program?** 48 | 49 | 50 | 51 | - Wloet o fCmuigCus ✅ 52 | - ecm t Jyo CmuigCus 53 | - Welcome to Joy of Computing Course 54 | - None of the above 55 | 56 | **7. What will the following function in the program do?** 57 | 58 | 59 | 60 | - Reverse all the strings in the sentence 61 | - Reverse the sentence ✅ 62 | - Reverse the first word of the sentence. 63 | - None of the above 64 | 65 | **8. Which of these methods can be used to transpose a matrix X?** 66 | 67 | - X.Transpose( ) 68 | - X.T ✅ 69 | - X.t( ) 70 | - X.transpose 71 | 72 | **9. What will the following program print?** 73 | 74 | 75 | 76 | - We cannot reshape the array. 77 | - [[ 1 2 3] ✅\ 78 | [ 4 5 6]\ 79 | [ 7 8 9] 80 | [10 11 12]] 81 | - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] 82 | 83 | **10. What is the output of the following program?** 84 | 85 | 86 | 87 | - 7 88 | - 12 89 | - 10 90 | - 21 ✅ 91 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 10/Week 10 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | large_string = input() 2 | small_strings = input().split() 3 | new_str = "" 4 | for i in small_strings: 5 | new_str += i 6 | if(set(large_string) == set(new_str) and len(large_string) == len(new_str)): 7 | print("Yes",end="") 8 | else: 9 | print("No",end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 10/Week 10 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | import random 2 | s = input() 3 | t = input() 4 | u = '' 5 | for i in s: 6 | u += chr((ord(i) - ord('A') + 5)%26 + ord('A')) 7 | l = list(t) 8 | l.sort() 9 | m = list(u) 10 | m.sort() 11 | if l == m: 12 | print('Yes',end='') 13 | else: 14 | print('No',end='') -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 11/README.md: -------------------------------------------------------------------------------- 1 | # Week 11 Quiz 💡 2 | 3 | **1. The Python library used for browser automation is** 4 | 5 | - numpy 6 | - browser 7 | - selenium ✅ 8 | - pyautogui 9 | 10 | **2. Which method is used to obtain the element with a matching link text value?** 11 | 12 | - find_element_by_link_text ✅ 13 | - find_element_by_name 14 | - find_element_by_tag_name 15 | - find_element_by_id 16 | 17 | **3. What does the method find_element_by_class_name do?** 18 | 19 | - The first element with the given tag name will be returned. 20 | - The first element with the matching class attribute name will be returned. ✅ 21 | - The first element with the matching name attribute value will be returned. 22 | - The first element with the matching CSS selector will be returned. 23 | 24 | **4. Which Python module allows us to work with date and time?** 25 | 26 | - dt 27 | - dtime 28 | - timedate 29 | - datetime ✅ 30 | 31 | **5. Which method enables us to see the current date and time?** 32 | 33 | - today( ) 34 | - current( ) 35 | - now( ) ✅ 36 | - curdate( ) 37 | 38 | **6. Which Python library allows us to perform time zone calculations?** 39 | 40 | - timezone( ) 41 | - tz( ) 42 | - pytz( ) ✅ 43 | - pytimezone( ) 44 | 45 | **7. What would be the output of : print(calendar.weekday(2021,10,9))** 46 | 47 | - 4 48 | - 5 ✅ 49 | - 3 50 | - 6 51 | 52 | **8. Which of the following conditional statements correctly return True for any leap year and False for any non-leap year?** 53 | 54 | - if ( ( year%100 == 0 or year%400 == 0 ) or (year%4 == 0 or year%100 != 0) ) 55 | - if ( ( year%100 == 0 and year%400 == 0) or (year%4 == 0 and year%100 != 0) ) ✅ 56 | - if ( ( year%100 == 0 and year%4 ==0 ) or year%400 == 0) 57 | - if ( ( year%100 == 0 or year%4 == 0 ) and year%400 == 0) 58 | 59 | **9. Which of the following statements can be used to print the calendar of October 2021?** 60 | 61 | - calendar.month(2021, 10) ✅ 62 | - calendar.month(10, 2021) 63 | - calendar.month(Oct) 64 | - calendar.month(Oct, 2021) 65 | 66 | **10. What would be the output of the statement : print(datetime.datetime(2021, 9, 16))?** 67 | 68 | - 2021-09-16 12:00:00 69 | - 2021-09-15 23:59:59 70 | - 2021-09-16 01:01:01 71 | - 2021-09-16 00:00:00 ✅ 72 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 11/Week 11 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | items = input() 2 | words = [word for word in items.split(",")] 3 | print(",".join(sorted(list(set(words)))), end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 11/Week 11 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | my_str = input() 2 | no_punct = "" 3 | for char in my_str: 4 | if char.isalnum() or char == ' ': 5 | no_punct = no_punct + char 6 | print(no_punct, end="") 7 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 11/Week 11 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def findLongestPalindrome(s): 2 | count = [0]*256 3 | for i in range(len(s)): 4 | count[ord(s[i])] += 1 5 | beg = "" 6 | mid = "" 7 | end = "" 8 | ch = ord('a') 9 | while ch <= ord('z'): 10 | if (count[ch] & 1): 11 | mid = ch 12 | count[ch] -= 1 13 | ch -= 1 14 | else: 15 | for i in range(count[ch]//2): 16 | beg += chr(ch) 17 | ch += 1 18 | end = beg 19 | end = end[::-1] 20 | return beg + chr(mid) + end 21 | 22 | n=int(input()) 23 | nums = [] 24 | 25 | for i in range(n): 26 | nums.append(len(findLongestPalindrome(input()))) 27 | for j in nums: 28 | print(j) 29 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 12/README.md: -------------------------------------------------------------------------------- 1 | # Week 12 Quiz 💡 2 | 3 | **1. In the point distribution method of page rank algorithm, at each iteration, each node shares its pagerank value by** 4 | 5 | - Randomly choosing one of its outgoing links and sharing all its pagerank value to the node connected to that link. 6 | - Dividing its pagerank value equally to all the outgoing links. ✅ 7 | - Dividing its pagerank value randomly to all the outgoing links. 8 | - Dividing its pagerank value to all the outgoing links with the value given being proportional to their outdegree. 9 | 10 | **2. In the random walk method, what is the next step when a sink node is encountered in the underlying graph?** 11 | 12 | - random node is chosen out of all the given nodes. ✅ 13 | - The node with the maximum number of incoming links is chosen. 14 | - The node with the maximum number of outgoing links is chosen. 15 | - The process stops at this stage. 16 | 17 | **3. According to the Google Page rank algorithm, the rank of a page depends on: A. Number of pages it is referring to** 18 | 19 | - Number of pages it is referring to. 20 | - Number of pages referring to it. ✅ 21 | - Rank of pages it is referring to. 22 | - Rank of pages referring to it. 23 | 24 | **4. Comment on the purpose of the following command** 25 | sorted(p.items(),key=operator.itemgetter(1)) 26 | - Sort the items of dictionary, p by key 27 | - Sort the items of dictionary, p by values ✅ 28 | - Sort the elements of list, p by values 29 | - Sort the items of Tuple, p by values 30 | 31 | **5. Which of the following is not true about Collatz Conjecture?** 32 | 33 | - If the previous term is even, the next term is one half the previous term. 34 | - If the previous term is odd, the next term is 3 times the previous term. ✅ 35 | - If the previous term is odd, the next term is 3 times the previous term plus 1. 36 | - No matter what value of n, the sequence will always reach 1. 37 | 38 | **6. The sequence based on 3n+1 problem will always reach** 39 | 40 | - True ✅ 41 | - False 42 | 43 | **7. What is the sequence obtained according to the 3m+1 algorithm for m=9?** 44 | 45 | - 28,14,7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1 ✅ 46 | - 28,14,7,22,11,34,52,26,13,40,20,10,5,16,8,4,2,1 47 | - 28,14,7,22,11,17,52,26,13,40,20,10,5,16,8,4,2,1 48 | - 28,14,7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1 49 | 50 | **8. Consider the following statements:** 51 | 52 | a) Random Walk method requires a lesser number of iterations to calculate accurate PageRank as compared to Points Distribution method.\ 53 | b) Points Distribution method requires lesser number of iterations to calculate accurate PageRank as compare to Random Walk method 54 | - Statement a is correct 55 | - Statement b is correct 56 | - Statement b is correct ✅ 57 | 58 | **9. In the web graph, nodes are the web pages. What are the edges?** 59 | 60 | - Network Connections 61 | - Links to other web pages ✅ 62 | - URLs 63 | - None of the above 64 | 65 | **10. How many iterations does the number, 75 take to converge in Collatz Conjecture?** 66 | 67 | - 14 ✅ 68 | - 15 69 | - 13 70 | - 12 71 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 12/Week 12 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | d=[int(i) for i in input().split()] 2 | s=sum(d) 3 | result=0 4 | if s%len(d)==0: 5 | for i in range(len(d)): 6 | if d[i]<(s//len(d)): 7 | result=result+((s//len(d))-d[i]) 8 | print(result,end='') 9 | else: 10 | print('-1',end='') -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 12/Week 12 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | x = list(map(int, input().split())) 2 | x.sort() 3 | print(x[-1] + x[-2], end="") 4 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 12/Week 12 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | for t in range(int(input())): 2 | n = int(input()) 3 | a = [int(i1) for i1 in input().split()] 4 | mn,mnidx,mx,mxidx=a[0],0,a[0],0 5 | 6 | for i in range(0,n): 7 | if a[i]mx: 11 | mx=a[i] 12 | mxidx=i 13 | 14 | val1 = max(mnidx,mxidx) 15 | val2 = min(mnidx,mxidx) 16 | print(min([val2-val1+1+n, val1+1,n-val2])) 17 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 2/README.md: -------------------------------------------------------------------------------- 1 | # Week 2 Quiz 💡 2 | 3 | **1. What will be the output for the following program if the user gives an input value of 3 to it?** 4 | 5 | 6 | 7 | - 15 8 | - 33333 ✅ 9 | - Error message 10 | - 555 11 | 12 | **2. Which of these statements in python will throw anerror when executed?** 13 | - print( “Hello” ) 14 | - print( ‘Hello’ ) 15 | - print( “ ‘Hello’ “ ) 16 | - print( “ “Hello” ” ) ✅ 17 | 18 | **3. What will be the output of the following code when executed?** 19 | 20 | 21 | 22 | - It will print numbers from 3 to 30 23 | - It will print multiples of 3 till 30 24 | - It will print multiples of 3 till 27 ✅ 25 | - It will print 3 thirty times 26 | 27 | **4. What will the output of the following code be when executed?** 28 | 29 | 30 | 31 | - 7.5\ 32 | 7 ✅ 33 | - 7.5\ 34 | 7.5 35 | - 7\ 36 | 7 37 | - 7.5\ 38 | 2 39 | 40 | **5. What value will c store in it after the execution of the below code?** 41 | 42 | 43 | 44 | - Value of b multiplied by 3 45 | - Cube of b 46 | - Value of b multiplied with 3 twice 47 | - It will throw an error ✅ 48 | 49 | **6. Python was named after the television show Monty Python's Flying Circus.** 50 | 51 | - False 52 | - True ✅ 53 | 54 | **7. What will the output of the following program be?** 55 | 56 | 57 | 58 | - < class 'str' > ✅ 59 | - < class 'int' > 60 | - < class 'number' > 61 | - < class 'variable ' > 62 | 63 | **8. What will the output of the following program be?** 64 | 65 | - It will show an error 66 | - Hello! Welcome to Joy of Computing using Python course ✅ 67 | - 47 68 | - a+b 69 | 70 | **9. The python files will be saved with a .python extension** 71 | 72 | - False ✅ 73 | - True 74 | 75 | **10. What is the output for the following program?** 76 | 77 | 78 | 79 | - True 80 | - False ✅ 81 | - It will display an error message 82 | - Boolean 83 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 2/Week 2 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | name = input() 2 | print("Hello " + name + " ! Welcome to JOCP", end="") 3 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 2/Week 2 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | print(num**2, end="") 3 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 2/Week 2 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | discount = num * (15/100) 3 | print(num - discount, end="") 4 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 3/README.md: -------------------------------------------------------------------------------- 1 | # Week 3 Quiz 💡 2 | 3 | **1. List items are ordered, changeable, and do not allow duplicate values. State true or false** 4 | - True 5 | - False ✅ 6 | 7 | **2. What will the output of the following program be?** 8 | 9 | 10 | 11 | - All numbers from 1 to 10 12 | - All even numbers from 1 to 10 13 | - All odd numbers from 1 to 10 ✅ 14 | - It will give an error 15 | 16 | **3. What will the output of the following program be?** 17 | 18 | 19 | 20 | - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 21 | - [1, 2, 3, 4, 5, 6, 7, 999, 8, 9, 10] ✅ 22 | - It will give an error 23 | - [999, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 24 | 25 | **4. Which command will insert the new element to the list at the end? Consider the name of the list to be Shopping and the new element to be inserted is “oil”.** 26 | 27 | - Shopping.append(“oil”) 28 | - Shopping.insert(len(Shopping),”oil”) 29 | - Both option a and b ✅ 30 | - Shopping.add(“oil”) 31 | 32 | **5. Which method is to find out how many times a particular list element occurs?** 33 | 34 | - count ✅ 35 | - repeat 36 | - unique 37 | - sum 38 | 39 | **6. Which of these methods is used to find the mean of the below defined list? a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]** 40 | 41 | - statistics.median(a) ✅ 42 | - stats.median(a) 43 | - median(a) 44 | - average(a) 45 | 46 | **7. Which of these following statements is true regarding trimmed mean?** 47 | 48 | - It removes a small percentage of the largest and smallest values before calculating the mean 49 | - Trimmed mean is also known as truncated mean 50 | - Both a and b are true ✅ 51 | - Trimmed mean removes a small percentage of largest value before calculating the mean 52 | 53 | **8. What is the output of the following program?** 54 | 55 | 56 | 57 | - H+e+l+l+o ✅ 58 | - +Hello+ 59 | - +H+e+l+l+o 60 | - +Hello 61 | 62 | **9. Which of these methods is used to jumble a given word and give an output separated by a “ , “ symbol? (Consider the string to be stored in variable a)** 63 | 64 | - “ , ”.join(random.sample(a, len(a))) ✅ 65 | - random.sample(a, len(a)).join( “ , “ ) 66 | - random.sample(a, len(a)) 67 | - It is not possible to jumble a word 68 | 69 | **10. Which method can be used to remove an element at a particular index from the list?** 70 | 71 | - pop( ) ✅ 72 | - delete( ) 73 | - discard( ) 74 | - The element cannot be removed 75 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 3/Week 3 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | l, b = map(int, input().split()) 2 | 3 | print(l*b, end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 3/Week 3 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | a, b, c = map(int, input().split()) 2 | max_num = max(a, b, c) 3 | min_num = min(a, b, c) 4 | print(max_num - min_num, end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 3/Week 3 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | int_num = list(map(int,input().split())) 2 | 3 | x, y, z = sorted(int_num) 4 | 5 | if x**2 + y**2 == z**2: 6 | 7 | print('YES', end="") 8 | 9 | else: 10 | print('NO', end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 4/README.md: -------------------------------------------------------------------------------- 1 | # Week 4 Quiz 💡 2 | 3 | **1. What is the magic constant or magic sum of a magic square of size 11?** 4 | 5 | - 671 ✅ 6 | - 121 7 | - It is not possible to find 8 | - Magic squares only exists for even size 9 | 10 | **2. In magic square, the first number will be stored at position (n/2, n-1). Let this position be (i, j). The second number will be stored at position 11 | (i+1, j-1). State whether the following statement is true or false.** 12 | 13 | - True 14 | - False ✅ 15 | 16 | **3. The below given matrix is a magic square. State whether the following statement is true or false** 17 | 18 | 19 | 20 | - False 21 | - True ✅ 22 | 23 | **4. What will the output of the following program be?** 24 | 25 | 26 | 27 | - In the year 1900, february has 28 days ✅ 28 | - In the year 1900, february has 29 days 29 | - In the year 1900, february has 0 days 30 | - It will throw an error 31 | 32 | **5. Consider today's date to be 06-06-2021 and the day after tomorrow is tuesday.. What will be the output of the following program?** 33 | 34 | 35 | 36 | - 22\ 37 | 0 ✅ 38 | 39 | - 0\ 40 | 22 41 | 42 | - Monday\ 43 | 29 44 | 45 | - 29\ 46 | Tuesday 47 | 48 | **6. What will the following program do?** 49 | 50 | 51 | 52 | - Print the sum of digits of a given number ✅ 53 | - Print the number by dividing it by 10 54 | - Print the reverse of the number 55 | - None of the above 56 | 57 | **7. Which program will choose an element from the below list and display it in jumbled order?** 58 | 59 | - ✅ 60 | 61 | - 62 | 63 | - 64 | 65 | - 66 | 67 | **8. There are a total of 100 cards of 25 different colors. How many minimum numbers of draws are required to guarantee that at least two drawn cards have the same color?** 68 | 69 | - 100 70 | - 26 ✅ 71 | - 25 72 | - 50 73 | 74 | **9. What does the following code snippet in python compute?** 75 | 76 | 77 | 78 | - Factorial of numbers from 0 to 15 79 | - Fibonacci series ✅ 80 | - None 81 | - Sequence of numbers from 0 to 15 82 | 83 | **10. Dobble game has a deck of 55 cards, each printed with eight different symbols. Any two cards always share one matching symbol only. State whether the above statement is true or false** 84 | 85 | - True ✅ 86 | - False 87 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 4/Week 4 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | 3 | factorial = 1 4 | 5 | for i in range(1, num+1): 6 | 7 | factorial *= i 8 | 9 | print(factorial, end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 4/Week 4 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | num = map(int, input().split()) 2 | 3 | count = 0 4 | 5 | for i in num: 6 | if i%3 == 0 or i%5 == 0: 7 | count += 1 8 | 9 | print(count, end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 4/Week 4 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | from math import factorial 2 | 3 | num = input().split() 4 | 5 | zeroes = factorial(num.count('0')) 6 | 7 | ones = factorial(num.count('1')) 8 | 9 | trails = factorial(len(num)) 10 | 11 | arrangements = trails // (zeroes * ones) 12 | 13 | print(arrangements, end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 5/New Week 5 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | lst = [int(x) for x in input().split()] 2 | 3 | k = int(input()) 4 | 5 | lst.sort() 6 | 7 | print(lst[-k], end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 5/README.md: -------------------------------------------------------------------------------- 1 | # Week 5 Quiz 💡 2 | 3 | **1. What will the output of the following program be?** 4 | 5 | 6 | 7 | - They are equal 8 | - They are not equal ✅ 9 | - It will throw an error 10 | 11 | **2. What will the output of the following program be?** 12 | 13 | 14 | 15 | - name Joy of computing\ 16 | Length 12 Weeks\ 17 | Professor_name Dr Sudarshan Iyengar\ 18 | Language Python ✅ 19 | - {'name': 'Joy of computing', 'Length': Sudarshan Iyengar', 'Language': 'Python'} 20 | - It will throw an error 21 | - dictB will be empty 22 | 23 | **3. A file with the .wav or .wave file extension is a Waveform Audio File Format. True or False?** 24 | 25 | - False 26 | - True ✅ 27 | 28 | **4. In the Monty Hall problem, under the standard assumptions, contestants who switch have a ___ chance of winning the car, while contestants 29 | who stick to their initial choice have only ____ chance.** 30 | 31 | - 1/2, 1/2 32 | - 2/3, 1/3 ✅ 33 | - 1/3, 2/3 34 | - 1/3, 1/3 35 | 36 | **5. In the game ‘Rock, Paper and Scissor’ , if player1 enters 123478 and player2 enters 347653 with the secrets bits as 3 and 5 respectively, then who wins the game? (Assume that player1_list=[“rock”, “paper”, “scissor”] and player2_list=[“paper” ,”scissor”, “rock”])** 37 | 38 | - Player1 wins the game 39 | - Player2 wins the game 40 | - It will be a draw ✅ 41 | - Insufficient data 42 | 43 | **6. Which is the fastest sorting algorithm?** 44 | 45 | - Bubble Sort 46 | - Bucket Sort 47 | - Quick Sort ✅ 48 | - Insertion Sort 49 | 50 | **7. Which of these following statements are true with respect to the program below?** 51 | 52 | 53 | 54 | - The value of sum will always be between 1 and 11 55 | - The value of sum will be from 2 to 12 ✅ 56 | - The value of sum will be within 12 57 | - The maximum value of sum cannot exceed 6 58 | 59 | **8. What is the average time complexity of binary search if the numbers are arranged in descending order and the search is unsuccessful?** 60 | 61 | - log2 (n+1) 62 | - log2 (n) ✅ 63 | - log2 (n^2) 64 | - None of the following 65 | 66 | **9. What Is the output of the following program?** 67 | 68 | 69 | 70 | - 100 71 | - 0 ✅ 72 | - 108 73 | - 109 74 | 75 | **10. Will the following program give an error?** 76 | 77 | 78 | 79 | - Yes 80 | - No ✅ 81 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 5/Week 5 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | lst = input().split() 2 | 3 | k = int(input()) 4 | 5 | for i in lst: 6 | if lst.count(i) == k: 7 | print(i, end="") 8 | break -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 5/Week 5 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | lst = [int(x) for x in input().split()] 2 | 3 | k = int(input()) 4 | 5 | lst.sort() 6 | 7 | print(lst[k-1], end="") 8 | 9 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 5/Week 5 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | lst1 = [int(x) for x in input().split()] 2 | 3 | lst2 = [] 4 | 5 | sum = 0 6 | 7 | for i in lst1: 8 | sum += i 9 | lst2.append(sum) 10 | 11 | print(*lst2,end="") 12 | 13 | #str1 = ' '.join([str(elem) for elem in lst2]) 14 | 15 | #print(str1, end="") 16 | 17 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 6/README.md: -------------------------------------------------------------------------------- 1 | # Week 6 Quiz 💡 2 | 3 | **1. If PYTHON is SVWERK, what is COMPUTING?** 4 | 5 | - FLPMXQLKJ ✅ 6 | - FRPSXWLQJ 7 | - Insufficient data 8 | - ZLJMSQFKD 9 | 10 | **2. What operation will the following program do?** 11 | 12 | 13 | 14 | - Shift the letter by 6 to the right and then print the capital of that letter. ✅ 15 | - Shift the letter by 6 to the left and then print the capital of that letter. 16 | - Shift the letter by 6 to the right and then print the small letter. 17 | - Shift the letter by 6 to the left and then print the small letter. 18 | 19 | **3. What is the output of the following program?** 20 | 21 | 22 | 23 | - False 24 | - True ✅ 25 | 26 | **4. What will be the output of the following program?** 27 | 28 | 29 | 30 | - ll,adwlolt o fcmuigcus 31 | - hlo n lcm ojyo optn orl ✅ 32 | - hello, and welcome to jy of computing course 33 | - It will show an error 34 | 35 | **5. The array object in NumPy is called ndarray and NumPy is faster than Lists. State whether the above statement is true or false.** 36 | 37 | - True ✅ 38 | - False 39 | 40 | **6. What is the output of the following program? ( Assuming that k and n are any 2 positive numbers)** 41 | 42 | 43 | 44 | - It will find the value of k raised to the power of k 45 | - It will find the value of n raised to the power of k 46 | - It will find the value of k raised to the power of n ✅ 47 | - It will find the value of n raised to the power of n 48 | 49 | **7. The output of the following program is as follows\ 50 | [[ 1 4 13]\ 51 | [ 2 2 9]\ 52 | [ 3 3 6]]\ 53 | What should be written in the empty blank in the following program to get the 54 | above desired output?** 55 | 56 | 57 | 58 | - numpy.transpose(arr) ✅ 59 | - arr.transpose( ) 60 | - Either a or b options can be used 61 | - arr.reverse( ) 62 | 63 | **8. Which of the following programs will calculate the factorial of a given number?** 64 | 65 | - 66 | 67 | - 68 | 69 | - ✅ 70 | 71 | - None of the following 72 | 73 | **9. In tic tac toe game, if player 1 starts the game by marking ‘X’ in the center of the matrix, then he has more chances of winning. State whether the above given statement is true or false.** 74 | 75 | - True ✅ 76 | - False 77 | 78 | **10. Recursive programs are faster than the iterative programs. State whether the following statement is true or false.** 79 | 80 | - True 81 | - False ✅ 82 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 6/Week 6 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | r,c =map(int, input().split()) 2 | 3 | mat=[[0 for i in range(c)]for j in range(r)] 4 | 5 | val=1 6 | 7 | for i in range(r): 8 | for j in range(c): 9 | mat[i][j]=val 10 | val=val+1 11 | 12 | for i in range(r): 13 | for j in range(c): 14 | if j !=(c-1): 15 | print(mat[i][j],end=" ") 16 | else: 17 | print(mat[i][j],end="") 18 | if i!=(r-1): 19 | print() -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 6/Week 6 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(1, n+1): 3 | print(str(i)*i) -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 6/Week 6 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | n=int(input()) 2 | l=[] 3 | for i in range(n): 4 | for j in range(1): 5 | temp=[int(g) for g in input().split()] 6 | l.append(temp) 7 | x=0 8 | for i in range(n): 9 | for j in range(n): 10 | if l[i][j]!=l[j][i]: 11 | x=x+1 12 | if x==0: 13 | print("Yes",end="") 14 | else: 15 | print("No",end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 7/README.md: -------------------------------------------------------------------------------- 1 | # Week 7 Quiz 💡 2 | 3 | **1. What will the following program do?** 4 | 5 | 6 | 7 | - Rename the snakesandladders.png file as snakeimage.png 8 | - Creates a new file called snakeimage.png 9 | - Creates a new file called snakeimage.png with the same content as in the snakesandladders.png ✅ 10 | - Invalid operation 11 | 12 | **2. Which of the following statements is wrong regarding csv?** 13 | 14 | - CSV stands for Comma Separated Values 15 | - It's a simple file format used to store tabular data, such as spreadsheet or database 16 | - The use of the commas a field separator is the source of the name for this file format 17 | - None of the above ✅ 18 | 19 | **3. If a player has a score of 87 and rolls the dice in the snake and ladder game. If he gets a 5, what will be the player's position next considering the dictionary associated with the game?** 20 | 21 | dict={ 22 | 92:79, 23 | 95:51, 24 | 87:18, 25 | 62:22, 26 | 57:40, 27 | 52:29, 28 | 17:13, 29 | 80:100, 30 | 90:91, 31 | 75:86, 32 | 58:77, 33 | 28:84, 34 | 8:30, 35 | 3:21 36 | } 37 | - 79 38 | - 97 39 | - 92 40 | - The player cannot be in position number 87 ✅ 41 | 42 | **4. What will be the output of the following program?** 43 | 44 | 45 | 46 | - 12 13 14 9 8 7 6 11 16 17 18 19 20 15 10 5 4 3 2 1 ✅ 47 | - 1 2 3 4 5 10 15 20 19 18 17 16 11 6 7 8 9 14 13 12 48 | - 1 6 11 16 17 18 19 20 15 10 5 4 3 2 7 12 13 14 9 8 49 | - 13 12 7 8 9 14 19 18 17 16 11 6 1 2 3 4 5 10 15 20 50 | 51 | **5. The default drawing state of the turtle is pendown. State whether the above statement is true or fault.** 52 | 53 | - True ✅ 54 | - False 55 | 56 | **6. What is the output of the following program?** 57 | 58 | 59 | 60 | - Octagon ✅ 61 | - Pentagon 62 | - Nonagon 63 | - Hexagon 64 | 65 | **7. While using the turtle speed method, the speed value 1 is faster than speed value 0. State whether the above statement is true or false.** 66 | 67 | - True 68 | - False ✅ 69 | 70 | **8. Which of these methods is used to make the turtle rotate 45 degrees in the anticlockwise direction.** 71 | 72 | - tr.turn(-45) 73 | - tr.right(-45) 74 | - tr.left(45) 75 | - Both b and c ✅ 76 | 77 | **9. Which of these packages allow us to plot data on google maps?** 78 | 79 | - gmplot ✅ 80 | - plot 81 | - googleplot 82 | - matplotlib.gmplot 83 | 84 | **10. Which of these following methods will change the color of the lines that will be drawn by the turtle?** 85 | 86 | - pencolor( ) ✅ 87 | - color( ) 88 | - Both a and b 89 | - None of the above 90 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 7/Week 7 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | n,m=map(int,input().split()) 2 | b=0 3 | 4 | for i in range(n): 5 | for j in range(1): 6 | temp=[int(g) for g in input().split()] 7 | for k in temp: 8 | if k!=0 and k!=1: 9 | b=b+1 10 | break 11 | 12 | if b==0: 13 | print("Yes",end="") 14 | else: 15 | print("No",end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 7/Week 7 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(1,n+1): 3 | print((((10**i)-1)//9)**2) -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 7/Week 7 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | n=int(input()) 2 | l=[] 3 | for i in range(n): 4 | for j in range(1): 5 | temp=[int(g) for g in input().split()] 6 | l.append(temp) 7 | 8 | 9 | for i in range(n): 10 | for j in range(n): 11 | if i 18 | 19 | - 1 2 3 ✅ 20 | - Error 21 | - a b c 22 | - t t t 23 | 24 | **4. What will be the output of the following program?** 25 | 26 | 27 | 28 | - It generates a random number and prints it 29 | - It generates a random number and doesn't do anything 30 | - It will generate a random number and prints it 31 | - It will generate a random number and prints it only if its a multiple of 3 ✅ 32 | 33 | **5. Which of these statements are false with respect to clahe?** 34 | 35 | - CLAHE is a variant of Adaptive histogram equalization ( AHE ) which takes care of over-amplification of contrast. 36 | - CLAHE operates on small regions in the image, called tiles, rather than the entire image. 37 | - The neighbouring tiles are then combined using bilinear interpolation by including the artificial boundaries. ✅ 38 | - It is used to improve the contrast of images. 39 | 40 | **6. What is the output of the following program?** 41 | 42 | 43 | 44 | - Linear graph with positive slope 45 | - Linear graph with negative slope ✅ 46 | - Non linear graph with positive slope 47 | - Non linear graph with negative slope 48 | 49 | **7. What should be filled in the blank in the given program to obtain the below desired output?** 50 | 51 | 52 | 53 | 54 | 55 | - pandas.DataFrame(data) 56 | - tiger.DataFrames(data) ✅ 57 | - tiger.Series(data) 58 | - pandas.Series(data) 59 | 60 | **8. VADER uses a combination of A sentiment lexicon is a list of lexical features which are generally labeled according to their semantic orientation as either positive or negative. State whether the following statement is true or false.** 61 | 62 | - True ✅ 63 | - False 64 | 65 | **9. What will the output of the following program be?** 66 | 67 | 68 | 69 | - Prints the reverse of string a 70 | - Prints the string only if its an anagram 71 | - Prints the string only if its a palindrome ✅ 72 | - Error message 73 | 74 | **10. If the compound score of a statement is 1.5. What can we infer from the compound statement?** 75 | 76 | - It is an extremely positive statement 77 | - It is and extremely negative statement 78 | - It is a neutral statement 79 | - Compound score cannot be 1.5 ✅ 80 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 8/Week 8 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def isPalindrome(s): 2 | 3 | return new_string.lower() == new_string[::-1].lower() 4 | 5 | # Driver code 6 | s = input() 7 | new_string = ''.join(char for char in s if char.isalnum()) 8 | 9 | 10 | ans = isPalindrome(s) 11 | 12 | if ans: 13 | print("Yes", end="") 14 | else: 15 | print("No", end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 8/Week 8 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | str_1 = input() 2 | 3 | str_2 = input() 4 | 5 | sorted_str1 = [] 6 | 7 | sorted_str2 = [] 8 | 9 | k = sorted(str_1.upper()) 10 | 11 | l = sorted(str_2.upper()) 12 | 13 | for i in k: 14 | if i.isalnum(): 15 | sorted_str1.append(i) 16 | 17 | for j in l: 18 | if j.isalnum(): 19 | sorted_str2.append(j) 20 | 21 | if sorted_str1 == sorted_str2: 22 | print("Yes", end="") 23 | else: 24 | print("No", end="") -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 8/Week 8 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | l = input().lower() 2 | s = 'abcdefghijklmnopqrstuvwxyz' 3 | for i in s: 4 | if i not in l: 5 | print('No',end='') 6 | break 7 | else: 8 | print('Yes',end='') -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 9/README.md: -------------------------------------------------------------------------------- 1 | # Week 9 Quiz 💡 2 | 3 | **1. Which of these features of the texts are not analyzed by the NLP for attributing authorship?** 4 | 5 | - Jaccard similarity 6 | - Stop words 7 | - Word Length 8 | - None of the above ✅ 9 | 10 | **2. NetworkX can be used to solve large-scale problems that require faster approaches. State whether the above statement is true or false.** 11 | 12 | - True 13 | - False ✅ 14 | 15 | **3. What is the output of the following program?** 16 | 17 | 18 | 19 | - ['b', 'c', 'd'] ✅ 20 | - ['b', 'a', 'c', 'd'] 21 | - It will give an error 22 | - ['d', 'a', 'c', 'b'] 23 | 24 | **4. Consider the following statements.** 25 | 26 | (1) subgraph(G, nbunch) - induce subgraph of G on nodes in nbunch\ 27 | (2) union(G1,G2) - graph union\ 28 | (3) disjoint_union(G1,G2) - graph union assuming all nodes are same\ 29 | (4) cartesian_product(G1,G2) - return Cartesian product graph 30 | 31 | **Which of the statements are correct with respect to the above operations?** 32 | 33 | - Only statements 1 and 2 are true 34 | - Only statements 1 and 3 are correct 35 | - All the above statements are correct 36 | - Statements 1, 2 and 4 are correct ✅ 37 | 38 | **5. Which of these following statements are true?** 39 | 40 | - Six degrees of separation is the idea that all people on average are six, or fewer, social connections away from each other 41 | - Six degrees of separation was originally developed by Frigyes Karinthy 42 | - It is also called six handshakes rule 43 | - All of the above ✅ 44 | 45 | **6. What does nltk stand for?** 46 | 47 | - Natural Language toolkit ✅ 48 | - Neutral Language toolkit 49 | - Natural Linguistic toolkit 50 | - Neutral Linguistic toolkit 51 | 52 | **7. The Barabasi-Albert model is a model that generates _________ networks.** 53 | 54 | - Scale-free networks ✅ 55 | - Scale networks 56 | 57 | **8. The complete graph with n graph vertices has how many undirected edges?** 58 | 59 | - n( n-1 )/2 ✅ 60 | - n-1 61 | - ( n-1 )/2 62 | - n 63 | 64 | **9. What will the following statement print?** 65 | 66 | - print(im.getpixel(coordinate)) 67 | - Prints the coordinate of a particular pixel 68 | - Prints the pixel RGB value specified by coordinate variable that contains both x and y value ✅ 69 | - Error message 70 | 71 | **10. What is the output of the following program?** 72 | 73 | 74 | 75 | - Hello python 76 | - HELLO PYTHON 77 | - HELLO python 78 | - hello python ✅ 79 | -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 9/Week 9 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | s = input().split(',') 2 | D = {} 3 | snake = 0 4 | ladder = 0 5 | for i in s: 6 | t = i.split(':') 7 | D[int(t[0])] = int(t[1]) 8 | for val in D: 9 | if D[val] > val: 10 | ladder += 1 11 | else: 12 | snake += 1 13 | print(str(snake)+' '+str(ladder),end='') -------------------------------------------------------------------------------- /Aug - Dec 2021 JOC Course/Week 9/Week 9 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | s = input().split(',') 2 | l = list(map(int,input().split(','))) 3 | D = {} 4 | count = 0 5 | for i in s: 6 | t = i.split(':') 7 | D[int(t[0])] = int(t[1]) 8 | for val in l: 9 | count += val 10 | if count in D: 11 | count = D[count] 12 | 13 | if count >= 100: 14 | print("Yes", end='') 15 | else: 16 | print("No", end='') -------------------------------------------------------------------------------- /Exam Pattern.md: -------------------------------------------------------------------------------- 1 | # Exam Pattern of JOC Course🔥 2 | 3 | 🔶 In Proctored / Center Based Examaination you will be getting only **Multiple Choice Question (MCQ)** with total 50 questions and The total duration of the examination is 180 minutes⏰. 4 | 5 | 🔶 The questions will be divided into 3 sections i,e, A, B, C respectively where, 6 | 7 | - **Section A :** contains 10 questions and 2 marks for each. 8 | 9 | - **Section B :** contains 15 questions and 2 marks for each. 10 | 11 | - **Section C :** contains 25 questions and 2 marks for each. 12 | 13 | ❗❗ Therefore, **Total Marks = 100** and for passing exam you have to score at least **40 marks** out of **100** or at least you have to correct **20 questions** for passing the examination.❗❗ 14 | 15 | ## 📌 How to prepare for the Exam❓🤷‍♂️ 16 | 17 | 1️⃣ You should solve all the **weekly quizzes** of your session as well as previous sessions and remember do not try to just muggings the questions apart from this try to understand concepts behind each and every questions. For previous sessions weekly quizzes **[CLICK HERE](https://github.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/tree/main/JOC%20previous%20years%20weekly%20quizes)** 18 | 19 | 2️⃣ Here is one trivia for all of you if you solved all the weekly quizzes then there is high probability that some questions will directly come from weekly quizzes that means **100% Copy Paste.** 20 | 21 | 3️⃣ There is also high chances of some questions that will directly come from weekly quizzes but, in that questions you will be getting different values or data. 22 | 23 | **⚠(Note : In my opinion seeing video lectures are not that important because in exam you'll be getting hardly 1 or 2 questions from the lectures.)⚠** 24 | 25 | ## 📌 Important topics for the exam🤔 26 | 27 | - String, List, Dictionary, Tuple, Set 28 | 29 | - Conditional Statements (For Loop & While Loop) 30 | 31 | - Random & Numpy Library 32 | 33 | - Basic Scratch & Turtle Problem (Only 2 or 3) 34 | 35 | - Graph (Finding degree of separartion & Finding number of edges questions) 36 | 37 | ## 📌 Things that are allowed and not allowed on the exam center🙄 38 | 39 | | **Permitted** | **Not Permitted** | 40 | |:---------------:|:------------------:| 41 | | You may bring vehicle keys inside the exam hall, You should bring your own pen/pencil; it would not be given at the examination centre | Analog/Smart/digital/programmable watches, wallets, mobile phones, bluetooth devices, microphones,pagers, health bands or any other electronic gadgets, any printed/blank/handwritten paper, log tables, writing pads, scales,geometry/pencil-boxes, pouches, calculators, pen drives, electronic pens, handbags, goggles | 42 | 43 | 44 | ## 📌 If still you have any doubt you can reach out to me or just open an issue here : 45 |

46 | kishan_rajput23 47 | https://www.linkedin.com/in/kishan-kumar-rai-23112000 48 | https://www.facebook.com/kishan.kumarrai.79 49 | kishan_rajput23 50 |

51 | -------------------------------------------------------------------------------- /JOC previous years weekly quizes/JOC 2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/JOC previous years weekly quizes/JOC 2018.pdf -------------------------------------------------------------------------------- /JOC previous years weekly quizes/JOC Jan-Apr 2021.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/JOC previous years weekly quizes/JOC Jan-Apr 2021.pdf -------------------------------------------------------------------------------- /JOC previous years weekly quizes/JOC Jan-Aug 2020.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/JOC previous years weekly quizes/JOC Jan-Aug 2020.pdf -------------------------------------------------------------------------------- /JOC previous years weekly quizes/JOC Sep-Dec 2020.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/JOC previous years weekly quizes/JOC Sep-Dec 2020.pdf -------------------------------------------------------------------------------- /JOC previous years weekly quizes/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/README.md: -------------------------------------------------------------------------------- 1 | # Exam Pattern of JOC Course🔥 2 | 3 | 🔶 In Proctored / Center Based Examaination you will be getting only **Multiple Choice Question (MCQ)** with total 50 questions and The total duration of the examination is 180 minutes⏰. 4 | 5 | 🔶 The questions will be divided into 3 sections i,e, A, B, C respectively where, 6 | 7 | - **Section A :** contains 10 questions and 2 marks for each. 8 | 9 | - **Section B :** contains 15 questions and 2 marks for each. 10 | 11 | - **Section C :** contains 25 questions and 2 marks for each. 12 | 13 | ❗❗ Therefore, **Total Marks = 100** and for passing exam you have to score at least **40 marks** out of **100** or at least you have to correct **20 questions** for passing the examination.❗❗ 14 | 15 | ## 📌 How to prepare for the Exam❓🤷‍♂️ 16 | 17 | 1️⃣ You should solve all the **weekly quizzes** of your session as well as previous sessions and remember do not try to just muggings the questions apart from this try to understand concepts behind each and every questions. For previous sessions weekly quizzes **[CLICK HERE](https://github.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/tree/main/JOC%20previous%20years%20weekly%20quizes)👈** 18 | 19 | 2️⃣ Here is one trivia for all of you if you solved all the weekly quizzes then there is high probability that some questions will directly come from weekly quizzes that means **100% Copy Paste.** 20 | 21 | 3️⃣ There is also high chances of some questions that will directly come from weekly quizzes but, in that questions you will be getting different values or data. 22 | 23 | **⚠(Note : In my opinion seeing video lectures are not that important because in exam you'll be getting hardly 1 or 2 questions from the lectures.)⚠** 24 | 25 | ## 📌 Important topics for the exam🤔 26 | 27 | - String, List, Dictionary, Tuple, Set 28 | 29 | - Conditional Statements (For Loop & While Loop) 30 | 31 | - Random & Numpy Library 32 | 33 | - Basic Scratch & Turtle Problem (Only 2 or 3) 34 | 35 | - Graph (Finding degree of separartion & Finding number of edges questions) 36 | 37 | ## 📌 Things that are allowed and not allowed on the exam center🙄 38 | 39 | | **Permitted** | **Not Permitted** | 40 | |:---------------:|:------------------:| 41 | | You may bring vehicle keys inside the exam hall, You should bring your own pen/pencil; it would not be given at the examination centre | Analog/Smart/digital/programmable watches, wallets, mobile phones, bluetooth devices, microphones,pagers, health bands or any other electronic gadgets, any printed/blank/handwritten paper, log tables, writing pads, scales,geometry/pencil-boxes, pouches, calculators, pen drives, electronic pens, handbags, goggles | 42 | 43 | 44 | ## 📌 If still you have any doubt you can reach out to me or just open an issue here : 45 |

46 | kishan_rajput23 47 | kishan-kumar-rai-23112000 48 | kishan_rajput23 49 |

50 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 0/README.md: -------------------------------------------------------------------------------- 1 | # 📌 Week 0 Quiz 2 | 3 | **1. The area of a circle A is the sum of areas of two small circles of diameter 10cm and 24 cm, the diameter of the circle A is?** 4 | - 14 5 | - 26 ✅ 6 | - 17 7 | - 34 8 | 9 | **2. If a couple of dice are thrown together what will be the probability of getting the same number on both dice?** 10 | - 1/6 ✅ 11 | - 1/36 12 | - 1/12 13 | - 1/3 14 | 15 | **3. The sum of the first 10 odd natural numbers is ____.** 16 | - 200 17 | - 210 18 | - 100 ✅ 19 | - 400 20 | 21 | **4. What is the smallest number divisible by both 18 and 57?** 22 | - 400 23 | - 350 24 | - 260 25 | - 342 ✅ 26 | 27 | **5. Total number of factors any prime number has?** 28 | - 3 29 | - 2 ✅ 30 | - 0 31 | - 1 32 | 33 | **6. The HFC of 12 and 18 is?** 34 | - 2 35 | - 3 36 | - 4 37 | - 6 ✅ 38 | 39 | **7. If two dice are thrown together what is the probability of getting an even number on both dice?** 40 | - 1/6 41 | - 1/36 42 | - 1/4 ✅ 43 | - 1/2 44 | 45 | **8. If a number between 1 and 30 is chosen at random what is the probability of getting a prime number?** 46 | - 2/3 47 | - 1/3 ✅ 48 | - 1/6 49 | - 11/13 50 | 51 | **9. If the radius has doubled the area of the circle will?** 52 | - 2 times 53 | - 4 times ✅ 54 | - 8 times 55 | - 16 times 56 | 57 | **10. If the perimeter of a circle is equal to that of a square, then the ratio of their areas is** 58 | - 22: 7 59 | - 14: 11 ✅ 60 | - 7: 22 61 | - 11: 14 62 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 10/README.md: -------------------------------------------------------------------------------- 1 | # 📌Week 10 Quiz 2 | 3 | **1. What is the output of the following code?** 4 | 5 | 6 | 7 | - HELLO EVERYONE 8 | - Hello Everyone 9 | - helloeveryone 10 | - hello everyone ✅ 11 | 12 | **2. type(9) will return?** 13 | - float 14 | - int ✅ 15 | - str 16 | - class 17 | 18 | **3. Output of the following code will be?** 19 | 20 | 21 | 22 | - hello 23 | - h.e.l.l.o ✅ 24 | - .h.e.l..l.o 25 | - .h.e.l.l.o 26 | 27 | **4. Which code snippet represent replacing all vowels with ‘_’ in a string?(suppose string name is s)** 28 | 29 | - 30 | 31 | - 32 | 33 | - 34 | 35 | - ✅ 36 | 37 | **5. What will be the output of the following list slicing** 38 | 39 | 40 | 41 | - ‘Joy of C’ 42 | - ‘ Joy of C’ ✅ 43 | - ‘Joy of Co’ 44 | - ‘ Joy of Co’ 45 | 46 | **6. What does the following code represent?** 47 | 48 | 49 | 50 | - Replacing all letters at odd index with ‘_’. 51 | - Replacing all vowels at odd index with ‘_’. 52 | - Replacing all vowels at even index with ‘_’. ✅ 53 | - Replacing all letters at even index with ‘_’. 54 | 55 | **7. What will be the output of the following code?** 56 | 57 | 58 | 59 | - [4 6] 60 | - [3 7] ✅ 61 | - [3 4] 62 | - None of the above 63 | 64 | **8. How to take a transpose of a matrix?** 65 | 66 | - 67 | 68 | - ✅ 69 | 70 | - 71 | 72 | - 73 | 74 | **9. Lossy and Lossless compressions are the same?** 75 | - True 76 | - False ✅ 77 | 78 | **10. What is the shape of the following numpy array?** 79 | 80 | numpy.array([ [1,2,3], [4,5,6] ]) 81 | 82 | - (2,3) ✅ 83 | - (3,2) 84 | - (3,3) 85 | - (2,2) 86 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 10/Week 10 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | SL=sorted(list(set(L))) 2 | IL=[0]*(max(SL)+1) 3 | for i in range(len(SL)): 4 | IL[SL[i]]=SL[i] 5 | print(*IL,end="") 6 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 10/Week 10 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def closestSchool(x, y, L): 2 | min=99999 3 | distance=[] 4 | for i in L: 5 | dis=((x-i[0])**2+(y-i[1])**2)**0.5 6 | distance.append(dis) 7 | if dis 24 | 25 | - Date and time in dd- mm-yy hh:MM:ss:ms respectively. 26 | - Time and date in hh:MM:ss:ms dd- mm-yy respectively. 27 | - Date and time in mm-dd-yy hh:MM:ss:ms respectively. 28 | - Date and time in yy- mm-dd hh:MM:ss:ms respectively. ✅ 29 | 30 | **5. We can use the same web drivers for different browsers** 31 | - True 32 | - False ✅ 33 | 34 | **6. What will be the output of the following code?** 35 | 36 | 37 | 38 | - Print the current date and time of all time zones. ✅ 39 | - Print the current date and time of specific time zones. 40 | - Print the current date of all time zones. 41 | - Print the current date of some specific time zones. 42 | 43 | **7. What will be the output if the system date is 10 December 2021(Friday)?** 44 | 45 | 46 | 47 | - 5 48 | - 3 49 | - 4 ✅ 50 | - error 51 | 52 | **8. Which statement will return the calendar for a whole year?** 53 | - calendar.month(year) 54 | - calendar(year) 55 | - calendar.prcal(year) ✅ 56 | - calendar.year(year) 57 | 58 | **9. By which statement we can come out from the loop?** 59 | - continue 60 | - leave 61 | - catch 62 | - break ✅ 63 | 64 | **10. How to check for the leap year?** 65 | - calendar.leap(year) ✅ 66 | - calendar.is_leap(year) 67 | - calendar.isleap(year) 68 | - calendar.checkleap(year) 69 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 11/Week 11 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | a=int(input()) 2 | b=int(input()) 3 | c=int(input()) 4 | L=[a,b,c] 5 | h=max(L) 6 | L.remove(h) 7 | if h**2==L[0]**2+L[1]**2: 8 | print("YES",end="") 9 | else: 10 | print("NO",end="") 11 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 11/Week 11 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | L=sorted(input().split("#"),reverse=True) 2 | print("#".join(L),end="") 3 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 11/Week 11 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | prime=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 2 | 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 3 | 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 4 | 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 5 | 257, 263, 269, 271, 277, 281, 283, 293] 6 | a=int(input()) 7 | b=int(input()) 8 | for i in range(a,b+1): 9 | if i not in prime: 10 | print(i) 11 | 12 | 13 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 12/README.md: -------------------------------------------------------------------------------- 1 | # 📌Week 12 Quiz 2 | 3 | **1. What is a sink?** 4 | - A node with no incoming edges. 5 | - A node with maximum incoming edges. 6 | - A node with maximum outgoing edges. 7 | - A node with no outgoing edges. ✅ 8 | 9 | **2. What should we do when encountered a sink?** 10 | - Stop the algorithm. 11 | - Start with the last node. 12 | - Randomly choose a node from all nodes. ✅ 13 | - Randomly choose a node from neighbor nodes. 14 | 15 | **3. In the page rank algorithm** 16 | - We randomly travel from node to node without any relationship. 17 | - We randomly travel from node to neighbor node. 18 | - The maximum visited node will be the leader. 19 | - B and C ✅ 20 | - A and C 21 | 22 | **4. If we perform the page rank algorithm on the web as a graph, which of the following is true?** 23 | - Websites are nodes and hyperlinks in websites are edges. ✅ 24 | - Hyperlinks in websites are nodes and websites are edges. 25 | - Websites will work as nodes and edges. 26 | - Hyperlinks will work as nodes and edges. 27 | 28 | **5. Which is the following graph?** 29 | 30 | 31 | 32 | - Triangle Graph 33 | - Directed Graph 34 | - Barbell Graph ✅ 35 | - Wheel graph 36 | 37 | **6. Which of the following is a star graph of node 5?** 38 | 39 | - ✅ 40 | 41 | - 42 | 43 | - 44 | 45 | - 46 | 47 | **7. What will be the G.out_degree(3) for the following graph(G)?** 48 | 49 | 50 | 51 | - 4 52 | - 5 ✅ 53 | - 3 54 | - 6 55 | 56 | **8. In the page rank algorithm the leader is decided by?** 57 | - A node(person) with maximum number of outgoing edges. 58 | - A node(person) with maximum number of incoming edges. 59 | - A node(person) which is visited maximum times. ✅ 60 | - Can not decide. 61 | 62 | **9. Which of the following is true about directed graphs?** 63 | - One can come back and forth from one node to another using a single edge. ✅ 64 | - One can only go forward from one node to another using a single edge. 65 | - One can go to any node from one node using one edge. 66 | - None of the above. 67 | 68 | **10. What will be the output of the following code?** 69 | 70 | 71 | 72 | - ['Hey', 'there', '!'] 73 | - ['Hey', 'there', ' ', '!'] 74 | - ['H', 'e', 'y', ' ', 't', 'h', 'e', 'r', 'e', '!'] ✅ 75 | - ['H', 'e', 'y', 't', 'h', 'e', 'r', 'e', '!'] 76 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 12/Week 12 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | print(int("".join(list(input())[::-1])),end="") -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 12/Week 12 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | L=input().split() 2 | M=[] 3 | for i in L: 4 | M.append("".join(list(i)[::-1])) 5 | ans=[] 6 | for i in sorted(M): 7 | ans.append("".join(list(i)[::-1])) 8 | print(ans,end="") 9 | 10 | 11 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 12/Week 12 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | roll=input() 2 | print(roll.split('@')[0],roll.split('@')[1].split(".")[0],end="") -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 2/README.md: -------------------------------------------------------------------------------- 1 | # 📌Week 2 Quiz 2 | 3 | **1. Which statement will print ‘The joy of computing’?** 4 | - print(The joy of computing) 5 | - print The joy of computing 6 | - printf(‘The joy of computing’) 7 | - print(‘The joy of computing’) ✅ 8 | 9 | **2. What is the output of the following code?** 10 | 11 | 12 | 13 | - Earth is round.\ 14 | Moon has lot of dust. 15 | - Earth is\ 16 | round.\ 17 | Moon has\ 18 | lot of dust. 19 | - Earth is\ 20 | round.\ 21 | Moon has lot of dust. ✅ 22 | - Earth is round.Moon has lot of dust. 23 | 24 | **3. What should be the syntax of getting age as an input from a user in python?** 25 | - Age = int(“Enter Age”) 26 | - Age = input(“Enter Age”) ✅ 27 | - Age = get(“Enter Age”) 28 | - Age = input(Enter Age) 29 | 30 | **4. What should be the value of _ to print all numbers from 0-10?** 31 | 32 | 33 | 34 | - 10 35 | - 9 36 | - 11 ✅ 37 | - None of the above 38 | 39 | **5. What will be the output of the following code?** 40 | 41 | 42 | 43 | - 0 44 | - 45 ✅ 45 | - 43 46 | - 50 47 | 48 | **6. What will be the output? suppose the input is 20** 49 | 50 | 51 | 52 | - 40 53 | - Error 54 | - 2020 ✅ 55 | - None of the above 56 | 57 | **7. What will be the output of the following code be?** 58 | 59 | 60 | 61 | - number is less than 0 62 | - number is greater than 0 63 | - number is zero 64 | - Error ✅ 65 | 66 | **8. What will be the output of the following code?** 67 | 68 | 69 | 70 | - 9 ✅ 71 | - 10 72 | - 0 73 | - None of the above 74 | 75 | **9. What will be the output of the following code?** 76 | 77 | 78 | 79 | - 56 ✅ 80 | - 45 81 | - 0 82 | - Error 83 | 84 | **10. What will be the output of the following code?** 85 | 86 | 87 | 88 | - 1,2,3,4,5,6,7,8,9,10 89 | - 2,4,6,8,10 ✅ 90 | - 0,1,2,3,4,5,6,7,8,9,10 91 | - Error 92 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 2/Week 2 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | print(num) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 2/Week 2 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | num1 = int(input()) 2 | num2 = int(input()) 3 | print(num1-num2) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 2/Week 2 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | for i in range(0, num+1): 3 | print(i) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 3/Week 3 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | L = [int(i) for i in input().split()] 2 | n = len(L) 3 | l = L[1:n:2] 4 | for i in l: 5 | print(i) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 3/Week 3 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | L = [int(i) for i in input().split()] 2 | L.sort() 3 | print(L[0:3]) 4 | 5 | new = L[-2:] 6 | print(new[::-1]) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 3/Week 3 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def all_even(L): 2 | for i in L: 3 | if i%2 == 0: 4 | print(i) 5 | 6 | L = [int(i) for i in input().split()] 7 | all_even(L) -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 4/Week 4 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | for i in range(1,n+1): 2 | for j in range(1, n+1): 3 | if(j <= n - i): 4 | print(' ', end = '') 5 | else: 6 | print('*', end = '') 7 | print() 8 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 4/Week 4 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | vowel = "AEIOUaeiou " 2 | for i in s: 3 | if i not in vowel: 4 | s = s.replace(i, "_") 5 | print(s) 6 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 4/Week 4 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | new = [x for x in L if L.count(x) == 2] 2 | 3 | res = [] 4 | [res.append(x) for x in new if x not in res] 5 | 6 | for i in res: 7 | print(i) 8 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 5/README.md: -------------------------------------------------------------------------------- 1 | # 📌 Week 5 Quiz 2 | 3 | **1. What is the syntax to create a dictionary?** 4 | - D = [] 5 | - D = {} ✅ 6 | - D = () 7 | - D = dictionary() 8 | 9 | **2. What is the correct statement about dictionaries?** 10 | - There can be multiple same keys. 11 | - Every value must be unique. 12 | - Every key must be unique. ✅ 13 | - We can’t get every key from the dictionary. 14 | 15 | **3. What is the correct syntax to get all the keys only from a dictionary d?** 16 | - d.key() 17 | - d.item() 18 | - d.value() 19 | - d.keys() ✅ 20 | 21 | **4. What will be the output of the following code?** 22 | 23 | 24 | 25 | - 20 ‘30’ ✅ 26 | - ‘20’ ‘30’ 27 | - 20 30 28 | - a b 29 | 30 | **5. What will be the output of the following code?** 31 | 32 | 33 | 34 | - ‘a’ ‘b’ ‘c’ 35 | - 20 30 50 36 | - ('a', 20), ('b', 30), ('c', 50) ✅ 37 | - (‘a’, ‘b’, ‘c’) (20, 30, 50) 38 | 39 | **6. What will be the output of the following code?** 40 | 41 | 42 | 43 | - Creates a dictionary with keys in range 0-19 and values 0 44 | - Creates a dictionary with keys in range a-t and values 0. ✅ 45 | - Creates a dictionary with keys in range a-z and values in range 0-19. 46 | - Creates a dictionary with keys in range a-t and values in range 0-19. 47 | 48 | **7. What does the following code mimics?** 49 | 50 | 51 | 52 | - Distribute 1000 marbles evenly in every bag. 53 | - Distribute 500 marbles randomly in every bag. 54 | - Distribute 1000 marbles randomly in every bag. ✅ 55 | - Throws an error. 56 | 57 | **8. What is the correct code to choose rock, paper, or scissors correctly?** 58 | 59 | - 60 | 61 | - 62 | 63 | - 64 | 65 | - ✅ 66 | 67 | **9. Binary search is applicable in?** 68 | - Unsorted list. 69 | - Only in the list which is sorted in ascending order. 70 | - Only in the list which is sorted in descending order. 71 | - Any sorted list. ✅ 72 | 73 | **10. What will be the output of the following code?** 74 | 75 | 76 | 77 | - The first element of the initial list. 78 | - The largest element of the list. ✅ 79 | - The smallest element of the list. 80 | - Throws an error. 81 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 5/Week 5 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def count_letters(string): 2 | d={} 3 | for s in string: 4 | if s not in d: 5 | d[s]=string.count(s) 6 | return(d) 7 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 5/Week 5 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def uniqueE(L): 2 | ans=[] 3 | for a in L: 4 | if L.count(a)==1: 5 | ans.append(a) 6 | return(sorted(ans)) 7 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 5/Week 5 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | prime_numbers=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 2 | 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 3 | 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 4 | 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293] 5 | for a in L: 6 | if a in prime_numbers: 7 | print(a,end="") 8 | break 9 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 6/README.md: -------------------------------------------------------------------------------- 1 | # Week 6 Quiz 2 | 3 | **1. The following code will** 4 | 5 | 6 | 7 | - Shift every letter in a given word by 'value'. ✅ 8 | - Shift every letter in a given word by 1. 9 | - Shift every letter in a given word by 26. 10 | - Returns the same word. 11 | 12 | **2. What will be the output of the following code if the input is ‘The Joy OF Computing’ ?** 13 | 14 | 15 | 16 | - Wjg Mqa Rh Fqorwvkpi 17 | - vjg lqa eh eqorwvkpi 18 | - Wjg Mqa RI Fqorwvkpi ✅ 19 | - vjg Mqa RI Fqorwvkpi 20 | 21 | **3. Which of the following is true about recursion?** 22 | - Recursion increases the speed of the program. 23 | - Recursion decreases the speed of the program. ✅ 24 | - Speed of the program remains the same. 25 | - Recursion is easier to understand than non-recursive programs. 26 | 27 | **4. What will be the output of the following program?** 28 | 29 | 30 | 31 | - Calculating sum of first n terms. 32 | - Calculating product of first n terms. ✅ 33 | - Calculating power of first n terms. 34 | - Calculating sum of last n terms. 35 | 36 | **5. What will be the output of the following program?** 37 | 38 | 39 | 40 | - 55 ✅ 41 | - 45 42 | - Infinite loop 43 | - 50 44 | 45 | **6. What is the output of the following program?** 46 | 47 | 48 | 49 | - 3628800 50 | - Runs into infinite loop ✅ 51 | - 55 52 | - Syntax error 53 | 54 | **7. What's the correct code for Binary search?** 55 | 56 | - 57 | 58 | - 59 | 60 | - ✅ 61 | 62 | - 63 | 64 | **8. What the following code will do?** 65 | 66 | 67 | 68 | - Returns product of elements from 5th index onwards. ✅ 69 | - Returns product of elements from 1st to 5th index. 70 | - Returns product of elements from 6th index onwards. 71 | - Returns product of elements from 4th index onwards. 72 | 73 | **9. A programme which is written in a recursive manner cannot be written in a non-recursive manner.** 74 | 75 | - True 76 | - False ✅ 77 | 78 | **10. what will be the output of the following program?** 79 | 80 | 81 | 82 | - 83 | 84 | - 85 | 86 | - Runs into infinite loop 87 | 88 | - ✅ 89 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 6/Week 6 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | print(sorted(L).index(L[K-1])+1,end="") -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 6/Week 6 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | Cap=list("ABCDEFGHIJKLMNOPQRSTUVMWXYZ") 2 | Small=list('abcdefghijklmnopqrstuvwxyz') 3 | ans="" 4 | for a in S: 5 | if a=='a': 6 | ans+='y' 7 | elif a=='b': 8 | ans+='z' 9 | elif a=='A': 10 | ans+='X' 11 | elif a=='B': 12 | ans+='Y' 13 | elif a=='C': 14 | ans+='Z' 15 | elif a=='W': 16 | ans+='T' 17 | else: 18 | if a in Cap: 19 | ans+=Cap[Cap.index(a)-3] 20 | elif a in Small: 21 | ans+=Small[Small.index(a)-2] 22 | else: 23 | ans+=a 24 | print(ans,end="") -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 6/Week 6 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def whole(N): 2 | return(sum(list(range(N+1)))) 3 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 7/README.md: -------------------------------------------------------------------------------- 1 | # Week 7 Quiz 2 | 3 | **1. Values of CSV files are separated by?** 4 | - Commas ✅ 5 | - Colons 6 | - Semi-colons 7 | - Slash 8 | 9 | **2. What is the output of the following code?** 10 | 11 | 12 | 13 | - 1, 2, 3, 7, 11, 10, 9, 5, 6 14 | - 1, 2, 3, 5, 6, 7, 9, 10, 11 15 | - 1, 5, 9, 10, 11, 7, 3, 2, 6 ✅ 16 | - 1, 5, 9, 2, 6, 10, 3, 7, 11 17 | 18 | **3. What will be the output of the following code?** 19 | 20 | 21 | 22 | - Scalar triangle 23 | - Right angle triangle 24 | - Equilateral triangle ✅ 25 | - Isosceles triangle 26 | 27 | **4. Which of the following program will draw a hexagon?** 28 | 29 | - 30 | 31 | - ✅ 32 | 33 | - 34 | 35 | - 36 | 37 | **5. Which of the following library is used to render data on google maps?** 38 | - gplot 39 | - googlemaps 40 | - gmplot ✅ 41 | - gmeplot 42 | 43 | **6. What is the output of the following code?** 44 | 45 | 46 | 47 | - 48 | 49 | - 50 | 51 | - 52 | 53 | - ✅ 54 | 55 | **7. Which turtle command is equivalent to lifting up a pen.** 56 | 57 | - penlift() 58 | - penup() ✅ 59 | - uppen() 60 | - penremove() 61 | 62 | **8. Why do we use functions?** 63 | 64 | - To improve readability. 65 | - To reuse code blocks. 66 | - For the ease of code debugging. 67 | - All of the above ✅ 68 | 69 | **9. Library used to import images?** 70 | 71 | - PIL ✅ 72 | - Imageview 73 | - IMG 74 | - image 75 | 76 | **10. In snakes and ladder what can be the ways to track ladders and snakes?** 77 | - Maintain a dictionary with snakes or ladder number blocks as keys. 78 | - Using the if condition to check on every number. 79 | - Both A and B. ✅ 80 | - None of the above 81 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 7/Week 7 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def DiagCalc(L): 2 | L_sum=0 3 | R_sum=0 4 | m=L[::-1] 5 | for i in range(len(L)): 6 | for j in range(len(L)): 7 | if i==j: 8 | L_sum+=L[i][j] 9 | R_sum+=m[i][j] 10 | print(L_sum) 11 | print(R_sum,end="") 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 7/Week 7 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | from array import * 3 | def Transpose(M): 4 | arr = numpy.array(M) 5 | num_list = arr.transpose().tolist() 6 | return(num_list) 7 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 7/Week 7 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def snake(M): 2 | s=0 3 | sm=[] 4 | for r in M: 5 | m=[] 6 | s=s+1 7 | if s%2==0: 8 | m=r[::-1] 9 | else: 10 | m=r 11 | sm+=m 12 | return(sm) 13 | 14 | 15 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 8/README.md: -------------------------------------------------------------------------------- 1 | # 📌Week 8 Quiz 2 | 3 | **1. What is the correct initialisation of tuples?** 4 | - Dates = [12,23,3,4] 5 | - Dates = (12,23,3,4) ✅ 6 | - Dates = {12,23,3,4} 7 | - Both B and C 8 | 9 | **2. What operations can be done on tuples?** 10 | - Tuples are appendable. 11 | - We can delete a value from tuples. 12 | - Both A and B. 13 | - We can count the number of instances of an element. ✅ 14 | 15 | **3. What will be the output of the following code?** 16 | 17 | 18 | 19 | - 1,2,3,4,5 20 | - 5,4,3,2,1 21 | - 5,4,3,2 ✅ 22 | - 1,2,3,4 23 | 24 | **4. What will be the output of the following code?** 25 | 26 | 27 | 28 | - facebook ✅ 29 | - gbdfcppl 30 | - ezbdannj 31 | - ytvxuhhd 32 | 33 | **5. When the following program will clap?** 34 | 35 | 36 | 37 | - When both players will enter the same letters. 38 | - When player 2 will enter the next letter with respect to player 1. ✅ 39 | - When player 1 will enter the next letter with respect to player 2. 40 | - It will never clap. 41 | 42 | **6. Which statement is correct about the following program?** 43 | 44 | 45 | 46 | - The graph will go up when guess and pick are the same. 47 | - The graph will go down when guess and pick are the same. 48 | - The graph will go up when guess and pick are not the same. 49 | - Both B and C ✅ 50 | 51 | **7. What does NLTK do?** 52 | - Helps to work with human language data. ✅ 53 | - Helps to convert machine data into human language. 54 | - Helps to work on gibberish language. 55 | - Helps to translate dog language into human language. 56 | 57 | **8. What is the output of the following code?** 58 | 59 | 60 | 61 | - ['!', 'e', 'e', 'e', 'h', 'h', 'r', 't', 'y'] 62 | - ['h', 'e', 'y', '!', 't', 'h', 'e', 'r', 'e'] 63 | - ['y', 't', 'r', 'h', 'h', 'e', 'e', 'e', '!'] ✅ 64 | - None of the above 65 | 66 | **9. While converting an image into black and white during enhancement you cannot convert it back into a colored image.** 67 | - True 68 | - False ✅ 69 | 70 | **10. The following code will** 71 | 72 | 73 | 74 | - Converting lower case letters into upper case. ✅ 75 | - Converting upper case letters into lower case. 76 | - Return the same word 77 | - Error 78 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 8/Week 8 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def squareT(t): 2 | L=[] 3 | for i in t: 4 | L.append(i*i) 5 | return(tuple(list(t)+L)) 6 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 8/Week 8 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def replaceV(s): 2 | a=s 3 | v=list("aeiou"+"AEIOU") 4 | for i in range(len(s)-2): 5 | if s[i] in v and s[i+1] in v and s[i+2] in v: 6 | a=a.replace(s[i]+s[i+1]+s[i+2],'_') 7 | return(a) 8 | 9 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 8/Week 8 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | z=[] 2 | a=[] 3 | for i in L: 4 | if i!=0: 5 | a.append(i) 6 | else: 7 | z.append(0) 8 | print(a+z,end="") -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 9/README.md: -------------------------------------------------------------------------------- 1 | # 📌Week 9 Quiz 2 | 3 | **1. How can we identify which book is written by which author?** 4 | - By matching handwriting. 5 | - By analyzing word length with previous books. ✅ 6 | - By analyzing the number of pages in a book. 7 | - By analyzing the book’s preface. 8 | 9 | **2. How can a list L can be converted into a tuple?** 10 | - tuple(L) ✅ 11 | - tup(L) 12 | - L(tuple) 13 | - L(tup) 14 | 15 | **3. Will the following piece of code always return True?** 16 | 17 | 18 | 19 | - True ✅ 20 | - False 21 | 22 | **4. What is the output of the following code?** 23 | 24 | 25 | 26 | - 27 | 28 | - 29 | 30 | - 31 | 32 | - ✅ 33 | 34 | **5. How many edges are there in the following graph?** 35 | 36 | 37 | 38 | - 4 ✅ 39 | - 5 40 | - 3 41 | - 2 42 | 43 | **6. How many neighbors does node 3 have?** 44 | 45 | 46 | 47 | - 2 48 | - 4 49 | - 1 50 | - 3 ✅ 51 | 52 | **7. In which of the following ways can we create a string in python?** 53 | 54 | - By using single quotes. 55 | - By using double-quotes. 56 | - By using triple-quotes. 57 | - All of the above. ✅ 58 | 59 | **8. How many nodes, edges does the following graph have?** 60 | 61 | 62 | 63 | - 10,6 ✅ 64 | - 10,5 65 | - 8,6 66 | - 8,5 67 | 68 | **9. A complete graph will have a degree of separation?** 69 | - 1 ✅ 70 | - 2 71 | - 3 72 | - Depends on the number of nodes. 73 | 74 | **10. How can we get an RGB of a pixel?** 75 | - RGB() 76 | - getpixel() ✅ 77 | - getvalue() 78 | - getrbg() 79 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 9/Week 9 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def subStr(s1,s2): 2 | return(s2 in s1) 3 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 9/Week 9 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def mergeDic(d1,d2): 2 | for k in d2: 3 | if k not in d1: 4 | d1[k]=d2[k] 5 | return(d1) 6 | -------------------------------------------------------------------------------- /Jan - Apr 2022 JOC Course/Week 9/Week 9 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | N=list(str(n)) 2 | P=[] 3 | for i in N: 4 | if i not in P: 5 | P.append(i) 6 | ans=[] 7 | for i in range(len(P)): 8 | a=[] 9 | for j in range(len(N)): 10 | if(P[i]==N[j]): 11 | a.append(j) 12 | ans.append(a) 13 | #print(ans) 14 | 15 | for i in range(len(P)): 16 | print(int(P[i]), "",end="") 17 | #print(len(ans[i])) 18 | for j in range(len(ans[i])): 19 | print(int(ans[i][j]),"",end="") 20 | print() 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Kishan Kumar Rai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Anagrams.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 21:40:57 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | elements=int(input("Enter the number of elements : ")) 9 | mylist=[] 10 | for _ in range(elements): 11 | mylist.append(input()) 12 | l=input("Enter whose anagram to be found") 13 | 14 | for i in range(len(mylist)): 15 | if sorted(l)== sorted(mylist[i]): 16 | print("found") 17 | print(mylist[i]) 18 | 19 | 20 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/AnalysisOfGraph.gexf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NetworkX 2.5 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/AreaCalculate.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 22 16:37:40 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | #here we will write a program to count the area of rajasthan 9 | 10 | #import image library from PIL 11 | 12 | #india rgba(254,190,109,255) 13 | #◘uja☻at rgba(238,28,37,255) ☺☻♥♦♣♠•◘○ 14 | 15 | 16 | from PIL import Image as im 17 | #import numpy as np 18 | import random 19 | 20 | img=im.open("India.jpg") 21 | rbg_img=img.convert("RGB") 22 | count_guj=0 23 | count_in=0 24 | count=0 25 | while(count<=10000): 26 | x=random.randint(0,789) #select a random point in image x and y are inverted in python 27 | y=random.randint(0,899) 28 | z=0 29 | r,g,b=rbg_img.getpixel((x,y)) 30 | if(r==254): 31 | count_in+=1 32 | count+=1 33 | elif r==238: 34 | count_guj+=1 35 | count+=1 36 | else: 37 | count+=1 38 | 39 | 40 | area_guj=(count_guj/count_in)*3287263 41 | print(area_guj) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/BinarySearch.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Feb 17 16:46:30 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | #binary search 9 | def binary_search(start,end,l,x): 10 | if start==end: 11 | if l[end]==x: 12 | return end 13 | else: 14 | return -1 15 | else: 16 | mid=int((start+end)/2) 17 | if(l[mid]==x): 18 | return mid 19 | elif(l[mid]>x): 20 | return binary_search(start,mid-1, l,x) 21 | elif(l[mid]l[i+1]): 16 | swap+=1 17 | n1=l[i] 18 | l[i]=l[i+1] 19 | l[i+1]=n1 20 | 21 | 22 | print(swap) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Calender.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Feb 14 10:06:39 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/CollatzConjecture.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def collatz(n): 4 | count=1 5 | while(n!=1): 6 | if(n%2==0): 7 | n=int(n/2) 8 | count+=1 9 | else: 10 | n=(n*3)+1 11 | count+=1 12 | 13 | print(count) 14 | 15 | number= int(input("Enter a number : ")) 16 | 17 | collatz(number) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Colorpicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 22 16:33:53 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | #here we will write a program to pick a RGB format from an image 9 | 10 | #import image library from PIL 11 | 12 | 13 | from PIL import Image as i 14 | im=i.open("RGB-Format.png"); 15 | rgb_im=im.convert('RGB') 16 | r,g,b=rgb_im.getpixel((150,1)) 17 | print(r,g,b) 18 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Conv_factor.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 15 14:12:27 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/DataTime.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Feb 14 13:43:28 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | import datetime 8 | dateToday=datetime.datetime.now() 9 | print(dateToday) 10 | dateToday=datetime.date.today().strftime("%Y") 11 | print(dateToday) #prints the year 12 | dateToday=datetime.date.today().strftime("%B") 13 | print(dateToday) #prints the month 14 | dateToday=datetime.date.today().strftime("%d") 15 | print(dateToday) #prints the date 16 | dateToday=datetime.date.today().strftime("%W") 17 | print(dateToday) #prints the week number of year 18 | dateToday=datetime.date.today().strftime("%w") 19 | print(dateToday) #prints the week number of month 20 | dateToday=datetime.date.today().strftime("%j") 21 | print(dateToday) #prints the day number of year 22 | dateToday=datetime.date.today().strftime("%A") 23 | print(dateToday) #prints the day -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/DateTime.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Feb 14 13:43:28 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | import datetime 8 | dateToday=datetime.datetime.now() 9 | print(dateToday) 10 | dateToday=datetime.date.today().strftime("%Y") 11 | print(dateToday) #prints the year 12 | dateToday=datetime.date.today().strftime("%B") 13 | print(dateToday) #prints the month 14 | dateToday=datetime.date.today().strftime("%d") 15 | print(dateToday) #prints the date 16 | dateToday=datetime.date.today().strftime("%W") 17 | print(dateToday) #prints the week number of year 18 | dateToday=datetime.date.today().strftime("%w") 19 | print(dateToday) #prints the week number of month 20 | dateToday=datetime.date.today().strftime("%j") 21 | print(dateToday) #prints the day number of year 22 | dateToday=datetime.date.today().strftime("%A") 23 | print(dateToday) #prints the day -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Dictionary.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 15 14:12:27 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | #Lets make a Dictionary named Conv_factor and it is denoted by {} 8 | conv_factor={} 9 | #lets set conv_factor of dollar to 60 10 | conv_factor["Dollar"]=60 11 | print(conv_factor) 12 | conv_factor["Euro"]=50 13 | print(conv_factor) 14 | print(conv_factor['Euro']) 15 | print(conv_factor.keys()) 16 | print(conv_factor.values()) 17 | print(conv_factor.items()) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/F.L.A.M.E.S.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 26 22:23:29 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | def remove_matching_letter(list1,list2): 9 | for i in range(len(list1)): 10 | for j in range(len(list2)): 11 | if list1[i]==list2[j]: 12 | c=list1[i] 13 | list1.remove(c) 14 | list2.remove(c) 15 | l=list1+["*"]+list2 16 | #print(l) 17 | return [l,True] 18 | l=list1+["*"]+list2 19 | return [l,False] 20 | 21 | 22 | boy=input("Enter boy's name: ") 23 | girl=input("Enter girl's name: ") 24 | 25 | boy=boy.lower() 26 | girl=girl.lower() 27 | boy=boy.replace(" ","") 28 | girl=girl.replace(" ","") 29 | 30 | l1=list(boy) 31 | l2=list(girl) 32 | proceed=True 33 | while proceed: 34 | # Traverse and point matching letter if No loop will exit 35 | ret_list=remove_matching_letter(l1,l2) 36 | #conconated list is returned at 0 place and at 1 bool 37 | con_list=ret_list[0] 38 | proceed=ret_list[1] 39 | #find the position of start index 40 | star_index=con_list.index("*") 41 | #divide the lists 42 | l1=con_list[:star_index] 43 | l2=con_list[star_index+1:] 44 | 45 | #counter=l1.count()+l2.count() 46 | counter=len(l1)+len(l2) 47 | 48 | result=["Friend","Loves","Affection","Marriage","Enemy","Sister"] 49 | 50 | while len(result)>1: 51 | #modular way of representation 52 | split_index=(counter%len(result))-1 53 | if split_index>0: 54 | right=result[split_index+1:] 55 | left=result[:split_index] 56 | result=right+left 57 | else: 58 | result=result[:len(result)-1] 59 | 60 | 61 | print(boy," ",result[0]," ",girl) 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/FibonacciRecur.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 11:04:49 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | 9 | def fibonacci(n): 10 | s=1 11 | const=n 12 | mylist=[0,1] 13 | #print(len(mylist)-1) 14 | while(n!=0): 15 | for i in range(len(mylist)-1): 16 | s+=mylist[i] 17 | if(s=0 and pixel[i,j]<=31): 31 | pixelNew[i,j]=0 32 | elif (pixel[i,j]>=32 and pixel[i,j]<=63): 33 | pixelNew[i,j]=1 34 | elif pixel[i,j]>=64 and pixel[i,j]<=95: 35 | pixelNew[i,j]=2 36 | elif pixel[i,j]>=96 and pixel[i,j]<=127: 37 | pixelNew[i,j]=3 38 | elif pixel[i,j]>=128 and pixel[i,j]<=159: 39 | pixelNew[i,j]=4 40 | elif pixel[i,j]>=160 and pixel[i,j]<=191: 41 | pixelNew[i,j]=5 42 | elif pixel[i,j]>=192 and pixel[i,j]<=223: 43 | pixelNew[i,j]=6 44 | elif pixel[i,j]>=224 and pixel[i,j]<255: 45 | pixelNew[i,j]=7 46 | 47 | 48 | img_new.save("Lena_compressed.bmp") 49 | j=np.asanyarray(ig.open("lena_compressed.bmp")) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/ImageTransposing.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 21:17:02 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | #Flipping the image 8 | from PIL import Image 9 | 10 | #opening the image 11 | img = Image.open('Recipt.jpg') 12 | 13 | #transpose of the matrix 14 | transposed_img=img.transpose(Image.FLIP_LEFT_RIGHT) 15 | 16 | #save it in a new file 17 | 18 | transposed_img.save("Corrected.png") 19 | 20 | print("Done!") 21 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/ImgEnhancing.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 21:24:23 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | #image enhancement CLAHE - Contrast Limited Adaptive Histogram Equalization 9 | import cv2 10 | 11 | #read the image 12 | img = cv2.imread('lalaram.jpg') 13 | 14 | #preparation for CLAHE 15 | clahe= cv2.createCLAHE() 16 | 17 | #COnvert to Gray Scale image 18 | 19 | gray_img= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 20 | 21 | #Lets apply enhancement finally 22 | 23 | ench_img=clahe.apply(gray_img) 24 | 25 | #And save it into a file 26 | 27 | cv2.imwrite('enhanced.jpg',ench_img) 28 | 29 | print("Done!!") 30 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/India.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/NPTEL-Course-Lecture Programmes/India.jpg -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/KmaxKmin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 13:45:46 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | mylist=input().split() 9 | k=int(input()) 10 | k1=k 11 | mylist1=mylist 12 | mylist1.sort() 13 | mylist.sort() 14 | max1=max(mylist1) 15 | #print(mylist,mylist1) 16 | #remove k-1th max from list1 and print max 17 | while(k1-1!=0): 18 | while(max(mylist1)==max1): 19 | mylist1.remove(max(mylist1)) 20 | 21 | max1=max(mylist1) 22 | k1-=1 23 | 24 | #remove k-1th min from list and print min 25 | min2=min(mylist) 26 | while(k-1!=0): 27 | while(min(mylist)==min2): 28 | mylist.remove(min(mylist)) 29 | 30 | min2=min(mylist1) 31 | k-=1 32 | 33 | #finally sum of kth max and kth min 34 | print(int(max(mylist1))+int(min(mylist))) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/MagicSquare.py: -------------------------------------------------------------------------------- 1 | # Python program to generate 2 | # odd sized magic squares 3 | # A function to generate odd 4 | # sized magic squares 5 | 6 | 7 | def generateSquare(n): 8 | 9 | # 2-D array with all 10 | # slots set to 0 11 | magicSquare = [[0 for x in range(n)] 12 | for y in range(n)] 13 | 14 | # initialize position of 1 15 | i = n / 2 16 | j = n - 1 17 | 18 | # Fill the magic square 19 | # by placing values 20 | num = 1 21 | while num <= (n * n): 22 | if i == -1 and j == n: # 3rd condition 23 | j = n - 2 24 | i = 0 25 | else: 26 | 27 | # next number goes out of 28 | # right side of square 29 | if j == n: 30 | j = 0 31 | 32 | # next number goes 33 | # out of upper side 34 | if i < 0: 35 | i = n - 1 36 | 37 | if magicSquare[int(i)][int(j)]: # 2nd condition 38 | j = j - 2 39 | i = i + 1 40 | continue 41 | else: 42 | magicSquare[int(i)][int(j)] = num 43 | num = num + 1 44 | 45 | j = j + 1 46 | i = i - 1 # 1st condition 47 | 48 | # Printing magic square 49 | print("Magic Squre for n =", n) 50 | print("Sum of each row or column", 51 | n * (n * n + 1) / 2, "\n") 52 | 53 | for i in range(0, n): 54 | for j in range(0, n): 55 | print('%2d ' % (magicSquare[i][j]), 56 | end='') 57 | 58 | # To display output 59 | # in matrix form 60 | if j == n - 1: 61 | print() 62 | 63 | # Driver Code 64 | 65 | 66 | # Works only when n is odd 67 | n = 5 68 | generateSquare(n) 69 | 70 | # This code is contributed 71 | # by Harshit Agrawal 72 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Making-an-Img.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Feb 20 21:37:05 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import numpy as np 9 | from PIL import Image 10 | 11 | #basically image is a matrix 12 | #dtype is datatype to be stored in matrix it is unsigned int 8 bits 13 | array1=np.zeros([100,200,3],dtype=np.uint8) 14 | array1[:,:100]=[200,128,61] #orange color 15 | array1[:,100:]=[60,128,80] 16 | #to make a image from the 2d matrix we made and provide rgb formats 17 | img=Image.fromarray(array1) 18 | 19 | #save the image 20 | img.save("RGB-Format.png") 21 | print("DONE!!!") 22 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Numpy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Feb 27 09:23:18 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | import numpy as np 8 | 9 | a=np.array([1,2,3]) 10 | 11 | #Type array 12 | print(type(a)) 13 | 14 | #shape (row,col) 15 | print(a.shape) 16 | 17 | print(a[0],a[1]) 18 | 19 | a[1]=6 20 | 21 | print(a[1]) 22 | 23 | 24 | b = np.zeros((2,2)) 25 | 26 | print(b) 27 | 28 | c = np.ones((2,2)) 29 | 30 | print(c) 31 | 32 | d=np.full((2,2),5) 33 | 34 | print(d) 35 | 36 | e=np.random.random((2,2)) 37 | 38 | print(e) 39 | 40 | #typecasting a array 41 | f=np.array([1,2],dtype=np.int64) 42 | 43 | print(f.dtype) 44 | 45 | # we can also type cast to float 64 //or data to identify itself 46 | 47 | g=np.array([0.0,2.0]) 48 | 49 | print(g.dtype) 50 | 51 | 52 | h=np.array([[1,2],[3,4]]) 53 | 54 | #transpose 55 | print(h.T) 56 | 57 | #sum of x ele 58 | print(np.sum(h)) 59 | 60 | 61 | #sum of col1 and col2 62 | 63 | print(np.sum(h,axis=0)) 64 | 65 | print(np.sum(h,axis=1)) 66 | 67 | print(np.multiply(h,g)) 68 | 69 | print(h-g) # or h+g or np.subtract(h,g) np.addition(h,g) 70 | 71 | print(np.sqrt(h)) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/NumpyMatrixOperations.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Feb 27 09:23:18 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | import numpy as np 8 | 9 | a=np.array([1,2,3]) 10 | 11 | #Type array 12 | print(type(a)) 13 | 14 | #shape (row,col) 15 | print(a.shape) 16 | 17 | print(a[0],a[1]) 18 | 19 | a[1]=6 20 | 21 | print(a[1]) 22 | 23 | 24 | b = np.zeros((2,2)) 25 | 26 | print(b) 27 | 28 | c = np.ones((2,2)) 29 | 30 | print(c) 31 | 32 | d=np.full((2,2),5) 33 | 34 | print(d) 35 | 36 | e=np.random.random((2,2)) 37 | 38 | print(e) 39 | 40 | #typecasting a array 41 | f=np.array([1,2],dtype=np.int64) 42 | 43 | print(f.dtype) 44 | 45 | # we can also type cast to float 64 //or data to identify itself 46 | 47 | g=np.array([0.0,2.0]) 48 | 49 | print(g.dtype) 50 | 51 | 52 | h=np.array([[1,2],[3,4]]) 53 | 54 | #transpose 55 | print(h.T) 56 | 57 | #sum of x ele 58 | print(np.sum(h)) 59 | 60 | 61 | #sum of col1 and col2 62 | 63 | print(np.sum(h,axis=0)) 64 | 65 | print(np.sum(h,axis=1)) 66 | 67 | print(np.multiply(h,g)) 68 | 69 | print(h-g) # or h+g or np.subtract(h,g) np.addition(h,g) 70 | 71 | print(np.sqrt(h)) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Pager.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Pager.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "authorship_tag": "ABX9TyMKeUnIj8EcnzZFX0G8CBVN", 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": { 31 | "id": "XezmL5su723M" 32 | }, 33 | "source": [ 34 | "## 🙂 Welcome \r\n", 35 | "


\r\n", 36 | "### 👇 Here we are reading nodes/edges from text file named page_rank.txt and are able to plot a graph , by making use of values present in files .\r\n", 37 | "\r\n", 38 | " [page_rank.txt](https://github.com/Lakhankumawat/LearnPython/blob/main/NPTEL-Course-Lecture%20Programmes/page_rank.txt)\r\n", 39 | "\r\n", 40 | " Program Code :\r\n", 41 | "\r\n" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "metadata": { 47 | "id": "_fwu9g2tFsMt" 48 | }, 49 | "source": [ 50 | "import networkx as nx\r\n", 51 | "import matplotlib.pyplot as plt\r\n", 52 | "\r\n", 53 | "G=nx.read_edgelist(r\"page_rank.txt\",create_using=nx.DiGraph,nodetype=str)\r\n", 54 | "\r\n", 55 | "nx.draw(G,with_labels=True)\r\n", 56 | "\r\n", 57 | "plt.show()" 58 | ], 59 | "execution_count": null, 60 | "outputs": [] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": { 65 | "id": "ohESCkvRFvY7" 66 | }, 67 | "source": [ 68 | "**Output Plot :**
\r\n", 69 | "\r\n", 70 | "[plot](https://github.com/Lakhankumawat/LearnPython/blob/main/NPTEL-Course-Lecture%20Programmes/Plot-img.png)\r\n" 71 | ] 72 | } 73 | ] 74 | } 75 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Players.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 12 22:44:01 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import random 9 | 10 | def choose(): 11 | words=['ram','lakhan','abhishek'] 12 | pick=random.choice(words) 13 | return pick 14 | 15 | def jumble(word): 16 | jumbled="".join(random.sample(word,len(word))) 17 | return jumbled 18 | 19 | def display(p1name,p2name,pp1,pp2): 20 | print(p1name," : ",pp1) 21 | print(p2name," : ",pp2) 22 | 23 | 24 | def play(): 25 | p1name = input("Player 1, please enter your name") 26 | p2name = input("Player 2, please enter your name") 27 | pp1=0 28 | pp2=0 29 | turn=0 30 | while(1): 31 | #computer's task 32 | picked_word=choose() 33 | qn=jumble(picked_word) 34 | print("Solve this : ",qn) 35 | #player 1 36 | if turn%2==0: 37 | print(p1name," its your turn") 38 | turn+=1 39 | ans = input("Please enter : ") 40 | if ans==picked_word: 41 | pp1+=1 42 | print("You were right :)") 43 | else: 44 | print("better luck next time") 45 | 46 | else: 47 | print(p2name," its your turn") 48 | turn+=1 49 | ans = input("Please enter : ") 50 | if ans==picked_word: 51 | pp2+=1 52 | else: 53 | print("better luck next time") 54 | choice=int(input("Continue 0 / exit 1")) 55 | if choice==0: 56 | print("Another one ") 57 | else: 58 | display(p1name,p2name,pp1,pp2) 59 | break 60 | 61 | play() 62 | 63 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Plot-img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/NPTEL-Course-Lecture Programmes/Plot-img.png -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Practice.py: -------------------------------------------------------------------------------- 1 | 2 | import networkx as nx 3 | import random as R 4 | import matplotlib.pyplot as plt 5 | 6 | def add_edges(): 7 | nodes=list(G.nodes()) 8 | for i in range(len(nodes)): 9 | for j in range(len(nodes)): 10 | if nodes[j]!=nodes[i]: 11 | rand=R.random() 12 | if rand<0.5: 13 | G.add_edge(i,j) 14 | 15 | return G 16 | 17 | def assign_points(G): 18 | nodes=list(G.nodes()) 19 | p=[] 20 | for _ in nodes: 21 | p.append(100) 22 | return p 23 | 24 | 25 | def distribute_points(G,points): 26 | nodes=list(G.nodes()) 27 | new_points=[] 28 | for i in range(len(nodes)): 29 | new_points.append(0) 30 | 31 | for n in nodes: 32 | out=list(G.out_edges(n)) 33 | if len(out): 34 | share=points[n]/len(out) 35 | for (src,tgt) in out: 36 | new_points[tgt]+=share 37 | else: 38 | new_points[n]=new_points[n]+points[n] 39 | return new_points 40 | 41 | 42 | def keep_distributing(points,G): 43 | 44 | while(1): 45 | new_pt=distribute_points(G,points) 46 | print(new_pt) 47 | points=new_pt 48 | stop=input("Press # to stop ,enter to continue") 49 | if stop=="#": 50 | break 51 | return new_pt 52 | 53 | 54 | def rank_points(final_points): 55 | #make a dictionary to assign key value pair 56 | d={} 57 | for i in range(len(final_points)): 58 | #Assigning key with points 59 | d[i]=final_points[i] 60 | 61 | #sort the dictionary on the basis of key which is here function lambda 62 | # where f is representing the dictionary f[1] denotes value at index 1 63 | print(sorted(d.items(),key=lambda f:f[1])) 64 | 65 | 66 | G=nx.DiGraph() 67 | G.add_nodes_from([i for i in range(10)]) 68 | G=add_edges() 69 | 70 | #Add labels to nodes 71 | nx.draw(G,with_labels=True) 72 | 73 | 74 | #Assign points to each nodes so that we can distribute later 75 | points = assign_points(G) 76 | 77 | 78 | #distribute points 79 | final_points=keep_distributing(points,G) 80 | 81 | 82 | #rank all the points 83 | rank_points(final_points) 84 | 85 | 86 | #lets compare with default networkx function to check whether our calculated results are matching the values calculated by default functions itself 87 | result=nx.pagerank(G) #Gives more upto 2 decimal places compared to our results 88 | print(sorted(result.items(),key=lambda f:f[1])) 89 | 90 | nx.draw(G) 91 | plt.show() 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Practice2.py: -------------------------------------------------------------------------------- 1 | #to rotate a line in python 2 | 3 | line= input().split(sep=",") 4 | line2=input().split(sep=",") 5 | dic={} 6 | point=0 7 | #to check fall or rise 8 | def check(no): 9 | p=0 10 | if no in dic: 11 | p=dic[no] 12 | return p 13 | 14 | 15 | for i in range(len(line)): 16 | spl=line[i].split(":") 17 | dic[spl[0]]=spl[1] 18 | 19 | 20 | for i in range(len(line2)): 21 | roll=int(line2[i]) 22 | point+=roll 23 | new_pt=check(point) 24 | if new_pt!=0: 25 | point=new_pt 26 | 27 | print(point) 28 | if point>=100: 29 | print("Yes") 30 | else: 31 | print('No') -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/RGB-Format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/NPTEL-Course-Lecture Programmes/RGB-Format.png -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/RandomWalkOnGraph.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Feb 28 12:51:16 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import networkx as nx 9 | import random 10 | import matplotlib.pyplot as plt 11 | import operator 12 | 13 | 14 | G=nx.gnp_random_graph(10,0.5,directed=True) 15 | 16 | nx.draw(G,with_labels=True) 17 | plt.show() 18 | 19 | #x is a random source node 20 | x=random.choice([i for i in range(G.number_of_nodes())]) 21 | 22 | dic_counter={} #to count the no of visit to nodes 23 | 24 | for i in range(G.number_of_nodes()): 25 | dic_counter[i]=0 26 | 27 | dic_counter[x]+=1 28 | 29 | for i in range(10000): 30 | list_n=list(G.neighbors(x)) #Get all the nodes of current node 31 | 32 | if(len(list_n)==0): #x is a leaf node no further traversal so choose a node randomly from graph to continue visit 33 | x=random.choice([ i for i in range(G.number_of_nodes(x))]) 34 | dic_counter[x]+=1 35 | else: 36 | x=random.choice(list_n) 37 | dic_counter[x]+=1 38 | 39 | #lets check the ranodmness by using python inbuilt function 40 | p=nx.pagerank(G) 41 | 42 | sorted_p=sorted(p.items(),key=operator.itemgetter(1)) #sorts on the basis of keys 43 | 44 | sorted_d=sorted(dic_counter.items(),key=operator.itemgetter(1)) 45 | 46 | 47 | print("I Applied : ",sorted_d) 48 | print("Machine applied : ",sorted_p) 49 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/RockPaperScissors.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Feb 16 17:27:17 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import random 9 | 10 | from tkinter import * 11 | 12 | #variables and Dictionary 13 | #These are total events that could occur if/else can also be used but they are pain to implement 14 | schema={ 15 | "rock":{"rock":1,"paper":0,"scissors":2}, 16 | "paper":{"rock":2,"paper":1,"scissors":0}, 17 | "scissors":{"rock":0,"paper":2,"scissors":1} 18 | } 19 | 20 | comp_score=0 21 | 22 | player_score=0 23 | 24 | #functions 25 | 26 | def outcome_handler(user_choice): 27 | global comp_score 28 | global player_score 29 | outcomes=["rock","paper","scissors"] 30 | num=random.randint(0, 2) 31 | computer_choice=outcomes[num] 32 | result=schema[user_choice][computer_choice] 33 | 34 | #now config the labes acc to the choices 35 | Player_Choice_Label.config(fg="green",text="Player choice : "+str(user_choice)) 36 | 37 | Computer_Choice_Label.config(fg="red",text="Computer choice : "+str(computer_choice)) 38 | 39 | if result==2: 40 | player_score+=2 41 | Player_Score_Label.config(text="Player : "+str(player_score)) 42 | Outcome_Label.config(fg="blue",bg="skyblue",text="Player-Won") 43 | elif result==1: 44 | player_score+=1 45 | comp_score+=1 46 | Player_Score_Label.config(text="Player : "+str(player_score)) 47 | Outcome_Label.config(fg="blue",bg="skyblue",text="Draw") 48 | Computer_Score_Label.config(text="Computer : "+str(comp_score)) 49 | elif result==0: 50 | comp_score+=2 51 | Outcome_Label.config(fg="blue",bg="skyblue",text="Computer-Won") 52 | Computer_Score_Label.config(text="Computer : "+str(comp_score)) 53 | #main Screen 54 | master=Tk() 55 | master.title("RPS") 56 | #labels 57 | Label(master,text="Rock , Paper , Scissors",font=("Calibri",15)).grid(row=0,sticky=N,pady=10,padx=200) 58 | 59 | Label(master,text="Please Select an option",font=("Calibri",12)).grid(row=2,sticky=N) 60 | 61 | Player_Score_Label=Label(master,text="Player : 0",font=("Calibri",12)) #label for player Score 62 | Player_Score_Label.grid(row=3,sticky=W) 63 | 64 | Computer_Score_Label=Label(master,text="Computer : 0",font=("Calibri",12)) #label for computer score 65 | Computer_Score_Label.grid(row=3,sticky=E) 66 | #player and computer choice labels 67 | Player_Choice_Label=Label(master,font=("Calibri",12)) 68 | Player_Choice_Label.grid(row=5,sticky=W) 69 | 70 | Computer_Choice_Label=Label(master,font=("Calibri",12)) 71 | Computer_Choice_Label.grid(row=5,sticky=E) 72 | #outcome Labels 73 | Outcome_Label=Label(master,font=("Calibri",12)) 74 | Outcome_Label.grid(row=5,sticky=N,pady=10) 75 | 76 | 77 | #buttons 78 | Button(master,text="Rock",width=17,command=lambda:outcome_handler("rock")).grid(row=6,sticky=W,padx=10,pady=10) 79 | Button(master,text="Paper",width=17,command=lambda:outcome_handler("paper")).grid(row=6,sticky=N,pady=10) 80 | Button(master,text="Scissors",width=17,command=lambda:outcome_handler("scissors")).grid(row=6,sticky=E,padx=10,pady=10) 81 | 82 | #dummy label to create space at the end of master screen 83 | Label(master).grid(row=5) 84 | master.mainloop() -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/SameLetterCards.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Feb 14 09:53:19 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import string 9 | import random 10 | symbols=[] 11 | symbols=list(string.ascii_letters) 12 | card1=[0]*5 13 | card2=[0]*5 14 | pos1=random.randint(0,4) 15 | pos2=random.randint(0,4) 16 | #first lets declare same symbol and extract it out 17 | samesymbol=random.choice(symbols) 18 | symbols.remove(samesymbol) 19 | if(pos1==pos2): 20 | card1[pos1]=samesymbol 21 | card2[pos2]=samesymbol 22 | else: 23 | card1[pos1]=samesymbol 24 | card2[pos2]=samesymbol 25 | card1[pos2]=random.choice(symbols) 26 | symbols.remove(card1[pos2]) 27 | card2[pos1]=random.choice(symbols) 28 | symbols.remove(card2[pos1]) 29 | 30 | i=0 31 | while(i<5): 32 | if(i!=pos1 and i!=pos2): 33 | card1[i]=random.choice(symbols) 34 | symbols.remove(card1[i]) 35 | card2[i]=random.choice(symbols) 36 | symbols.remove(card2[i]) 37 | i+=1 38 | print(card1) 39 | print(card2) 40 | ch=input('Spot same symbol: ') 41 | if(ch==samesymbol): 42 | print("Correct") 43 | else: 44 | print("Wrong") 45 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Sorted_KeyWord.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Feb 20 21:03:29 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | #Sorted keyword in python 9 | #lets sort a tuple 10 | tup=("c","a","b") 11 | print(sorted(tup)) 12 | 13 | #when we use sorted in dictionary it will by default sort by keys 14 | dic={3:"c",2:"b",1:"a"} 15 | print(sorted(dic)) 16 | print(dic) 17 | 18 | #lets sort a list on the basis of length 19 | L=["aaaa","bbb","cc"] 20 | print(sorted(L,key=len)) 21 | 22 | 23 | #however we can use sorted to sort by other parameters 24 | 25 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Testing.txt: -------------------------------------------------------------------------------- 1 | Construction of the mausoleum was essentially completed in 1643, but work continued on other phases of the project for another 10 years. 2 | The Taj Mahal complex is believed to have been completed in its entirety in 1653 at a cost estimated at the time to be around 32 3 | million rupees, which in 2020 would be approximately 70 billion rupees (about U.S. $956 million). -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Testing_op.txt: -------------------------------------------------------------------------------- 1 | Construction of the mausoleum was essentially completed in 1643, but work continued on other phases of the project for another 10 years. 2 | The Taj Mahal complex is believed to have been completed in its entirety in 1653 at a cost estimated at the time to be around 32 3 | million rupees, which in 2020 would be approximately 70 billion rupees (about U.S. $956 million). -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Timezones.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Feb 27 14:57:49 2021 4 | 5 | @author: Lakhan Kumawat 6 | 7 | 8 | from datetime import datetime as dt 9 | import pytz 10 | print(dt.now()) 11 | 12 | 13 | tz=pytz.timezone('Asia/Bangkok') 14 | 15 | print(dt.now(tz)) 16 | """ 17 | 18 | import calendar 19 | days=["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"] 20 | 21 | find=input().split() 22 | lis=list(find) 23 | try: 24 | dayNumber = calendar.weekday(int(lis[2]), int(lis[0]),int(lis[1])) 25 | print(days[dayNumber]) 26 | except Exception as e: 27 | 28 | print(e) 29 | 30 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/Tuple.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 21:41:10 2021 4 | 5 | @author: Lakhan Kumawat 6 | 7 | A Tuple is a collection of Python objects separated by commas. 8 | In someways a tuple is similar to a list in terms of indexing, 9 | nested objects and repetition but a tuple is immutable unlike lists which are mutable. 10 | 11 | Tuples are faster to access than lists since they are immutable 12 | 13 | just like in list we have [] 14 | and in dictionary {} 15 | in tuple we have 16 | """ 17 | tuple1 = (0, 1, 2, 3) 18 | 19 | 20 | tuple2=("Buggati","RolceRoyce","Strawberry","Buggati") 21 | print(tuple2) 22 | 23 | 24 | # Concatenating above two 25 | print(tuple1 + tuple2) 26 | 27 | #print length 28 | print(len(tuple2)) 29 | 30 | #prints the no. of times buggati arrived in tuple :D 31 | print(tuple2.count("Buggati")) 32 | 33 | #prints the index of the no or word (considers first occurence) 34 | print("Index of strawberry tuple data is : ",tuple2.index("Strawberry")) 35 | 36 | #tuple repetition 37 | tuple3 = ('python',)*3 38 | print(tuple3) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/lena.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/NPTEL-Course-Lecture Programmes/lena.bmp -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/monteHall.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Feb 16 17:05:42 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import random 9 | doors=[0]*3 10 | fakedoor=[0]*2 11 | swap=0 #to store the number of swap wins 12 | not_swap=0 #to store the non)swap wins 13 | j=0 14 | while(j<10): 15 | x=random.randint(0, 2) 16 | doors[x]="BMW" 17 | for i in range(0,3): 18 | if i==x: 19 | continue 20 | else: 21 | doors[i]="Fake" 22 | fakedoor.append(i) 23 | choice=int(input("Enter your choice in 0,1,2 : " )) 24 | door_open=random.choice(fakedoor) 25 | while(door_open==choice): #to make a different door open other than user 26 | door_open=random.choice(fakedoor) 27 | print("There is nothing in Door",door_open) 28 | swap_choice=input("Wanna swap ? 0/1 y/n : ") 29 | if(swap_choice=="y"): 30 | if(doors[choice]=="Fake"): 31 | print("Win") 32 | swap+=1 33 | else: 34 | print("Lose") 35 | else: 36 | if(doors[choice]=="Fake"): 37 | print("Lose") 38 | else: 39 | print("Win") 40 | not_swap+=1 41 | j+=1 42 | 43 | print("Swap Wins : ",swap) 44 | print("Non Swap wins: ",not_swap) -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/page_rank.txt: -------------------------------------------------------------------------------- 1 | a b 2 | a c 3 | a d 4 | b a 5 | b c 6 | b d 7 | c a 8 | c e 9 | d a -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/snakes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/7399b376bfcc5e9be4b8f12698d9faaa4f0ca5f3/NPTEL-Course-Lecture Programmes/snakes.jpg -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/substitutionCipher.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Feb 19 10:51:39 2021 4 | 5 | @author: Lakhan Kumawat 6 | """ 7 | 8 | import string 9 | dict={} 10 | data="" 11 | file=open("Testing_op.txt","w") 12 | for i in range(len(string.ascii_letters)): 13 | dict[string.ascii_letters[i]]=string.ascii_letters[i-2] 14 | #print(dict) 15 | with open("Testing.txt") as f: 16 | while True: 17 | c= f.read(1) 18 | if not c: 19 | print("EOF!!") 20 | break 21 | if c in dict: 22 | data=dict[c] 23 | else: 24 | data=c 25 | file.write(data) 26 | 27 | file.close() 28 | with open("Testing_op.txt","r+") as myfile: 29 | print(myfile.read()) 30 | 31 | myfile.close() -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/temp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Spyder Editor 4 | 5 | This is a temporary script file. 6 | """ 7 | "Hello World" 8 | print("hi") 9 | -------------------------------------------------------------------------------- /NPTEL-Course-Lecture Programmes/template.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on %(date)s 4 | 5 | @author: %(username)s 6 | """ 7 | 8 | -------------------------------------------------------------------------------- /Online Programming Test Solution/README.md: -------------------------------------------------------------------------------- 1 | 2 | # 1st Exam Solution 3 | ```python 4 | al = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" 5 | al = al.split(" ") 6 | 7 | 8 | def get_index(ch): 9 | for i in range(len(al)): 10 | if ch == al[i]: 11 | return i 12 | 13 | 14 | def get_cj(ch): 15 | return al[(get_index(ch) + 5) % 26] 16 | 17 | 18 | def get_cifar(st): 19 | st = [get_cj(i) for i in st] 20 | return ''.join(st) 21 | 22 | 23 | def get_counted_letter(wo): 24 | data = {} 25 | for ch in wo: 26 | if ch in data.keys(): 27 | data[ch] += 1 28 | else: 29 | data[ch] = 1 30 | return data 31 | 32 | 33 | def check_cifar(wr, ci): 34 | cdata = get_counted_letter(get_cifar(wr)) 35 | gcdata = get_counted_letter(ci) 36 | cdata_keys = cdata.keys() 37 | gcdata_keys = gcdata.keys() 38 | for i in cdata_keys: 39 | if i not in gcdata_keys: 40 | return False 41 | if cdata[i] != gcdata[i]: 42 | return False 43 | return True 44 | 45 | 46 | wr = input() 47 | ci = input() 48 | if (check_cifar(wr, ci)): 49 | print("Yes", end="") 50 | else: 51 | print("No", end="") 52 | ``` 53 | -------------------------------------------------------------------------------- /Online Programming Test Solution/evening session solution.py: -------------------------------------------------------------------------------- 1 | x = [int(i) for i in input().split()] 2 | 3 | moves = 0 4 | 5 | temp = sum(x) 6 | 7 | 8 | 9 | if temp % len(x) == 0: 10 | 11 | for j in range(len(x)): 12 | 13 | if x[j] < (temp // len(x)): 14 | 15 | moves = moves + ((temp // len(x))- x[j]) 16 | 17 | print(moves,end='') 18 | 19 | else: 20 | 21 | print('-1',end='') -------------------------------------------------------------------------------- /Online Programming Test Solution/exam_1.py: -------------------------------------------------------------------------------- 1 | al = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" 2 | al = al.split(" ") 3 | 4 | 5 | def get_index(ch): 6 | for i in range(len(al)): 7 | if ch == al[i]: 8 | return i 9 | 10 | 11 | def get_cj(ch): 12 | return al[(get_index(ch) + 5) % 26] 13 | 14 | 15 | def get_cifar(st): 16 | st = [get_cj(i) for i in st] 17 | return ''.join(st) 18 | 19 | 20 | def get_counted_letter(wo): 21 | data = {} 22 | for ch in wo: 23 | if ch in data.keys(): 24 | data[ch] += 1 25 | else: 26 | data[ch] = 1 27 | return data 28 | 29 | 30 | def check_cifar(wr, ci): 31 | cdata = get_counted_letter(get_cifar(wr)) 32 | gcdata = get_counted_letter(ci) 33 | cdata_keys = cdata.keys() 34 | gcdata_keys = gcdata.keys() 35 | for i in cdata_keys: 36 | if i not in gcdata_keys: 37 | return False 38 | if cdata[i] != gcdata[i]: 39 | return False 40 | return True 41 | 42 | 43 | wr = input() 44 | ci = input() 45 | if (check_cifar(wr, ci)): 46 | print("Yes", end="") 47 | else: 48 | print("No", end="") 49 | -------------------------------------------------------------------------------- /Online Programming Test Solution/solutions.py: -------------------------------------------------------------------------------- 1 | plain_text = input() 2 | encrypted_text = input() 3 | 4 | output = '' 5 | for c in plain_text: 6 | output+=chr((ord(c)+5-ord('A'))%26 + ord('A')) 7 | 8 | 9 | def removeSpaces(str): 10 | str = str.replace(' ','') 11 | str = str.replace(',','') 12 | return string.lower() 13 | def check(output, encrypted_text): 14 | 15 | # the sorted strings are checked 16 | if(sorted(output)== sorted(encrypted_text)): 17 | print("Yes",end='') 18 | else: 19 | print("No",end='') 20 | 21 | check(output, encrypted_text) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NPTEL-The-Joy-of-Computing-using-Python🔥 2 | 3 | ## THE JOY OF COMPUTING USING PYTHON 4 | 5 | ![NPTEL-The-Joy-of-Computing-using-Python](https://socialify.git.ci/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/image?description=1&font=Bitter&forks=1&issues=1&language=1&name=1&owner=1&pulls=1&stargazers=1&theme=Dark) 6 | 7 | ### Here is the course link : [CLICK HERE](https://onlinecourses.nptel.ac.in/noc21_cs75/preview) 8 | 9 | ### Want To Know Exam Pattern : [CLICK HERE](https://github.com/kishanrajput23/NPTEL-The-Joy-of-Computing-using-Python/blob/main/Jan%20-%20Apr%202022%20JOC%20Course/README.md) 👈 10 | 11 | A fun filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love with the most sought after skill of the 21st century. The course brings programming to your desk with anecdotes, analogies and illustrious examples. Turning abstractions to insights and engineering to art, the course focuses primarily to inspire the learner's mind to think logically and arrive at a solution programmatically. As part of the course, you will be learning how to practice and culture the art of programming with Python as a language. At the end of the course, we introduce some of the current advances in computing to motivate the enthusiastic learner to pursue further directions. 12 | 13 | ### [Introduction The Joy of Computing using Python](https://youtu.be/vgoffYa7_7E) 14 | 15 | **📌 INTENDED AUDIENCE :** Any interested audience 16 | 17 | **📌 PREREQUISITES :** 10th standard/high school 18 | 19 | **📌 INDUSTRY SUPPORT :** Every software company is aware of the potential of a first course in computer science. Especially of a first course in computing, done right. 20 | 21 | **📌 COURSE TYPE :** Elective 22 | 23 | **📌 COURSE LEVEL :** Undergraduate/Postgraduate 24 | 25 | **📌 COURSE LAYOUT :** 26 | - Motivation for Computing 27 | - Welcome to Programming!! 28 | - Variables and Expressions : Design your own calculator 29 | - Loops and Conditionals : Hopscotch once again 30 | - Lists, Tuples and Conditionals : Lets go on a trip 31 | - Abstraction Everywhere : Apps in your phone 32 | - Counting Candies : Crowd to the rescue 33 | - Birthday Paradox : Find your twin 34 | - Google Translate : Speak in any Language 35 | - Currency Converter : Count your foreign trip expenses 36 | - Monte Hall : 3 doors and a twist 37 | - Sorting : Arrange the books 38 | - Searching : Find in seconds 39 | - Substitution Cipher : What’s the secret !! 40 | - Sentiment Analysis : Analyse your Facebook data 41 | - 20 questions game : I can read your mind 42 | - Permutations : Jumbled Words 43 | - Spot the similarities : Dobble game 44 | - Count the words : Hundreds, Thousands or Millions. 45 | - Rock, Paper and Scissor : Cheating not allowed !! 46 | - Lie detector : No lies, only TRUTH 47 | - Calculation of the Area : Don’t measure. 48 | - Six degrees of separation : Meet your favourites 49 | - Image Processing : Fun with images 50 | - Tic tac toe : Let’s play 51 | - Snakes and Ladders : Down the memory lane. 52 | - Recursion : Tower of Hanoi 53 | - Page Rank : How Google Works !! 54 | -------------------------------------------------------------------------------- /Week0/README.md: -------------------------------------------------------------------------------- 1 | # Week 0 Quiz 💡 2 | 3 | **1. What are the prime factors of the number 124** 4 | - 2,62 5 | - 2,31 ✅ 6 | - 1,124 7 | - None of the above 8 | 9 | **2. What is the Lowest Common multiple of 5,15** 10 | - 5 11 | - 10 12 | - 15 ✅ 13 | - 20 14 | 15 | **3. A car traveled 281 km in 4 hours 41 minutes. What was the average speed of the car in km per minute?** 16 | - 1 ✅ 17 | - 2 18 | - 3 19 | - 4 20 | 21 | **4. The length of a rectangle is four times its width. If the area is 100m2 what is the width of the rectangle?** 22 | - 10 23 | - 5 ✅ 24 | - 4 25 | - 6 26 | 27 | **5. The length of a rectangle is increased to 2 times its original size and its width is increased to 3 times its original size. If the area of the new rectangle is equal to 1800 square meters, what is the area of the original rectangle?** 28 | - 1200 square meters 29 | - Remains same 30 | - 300 square meters ✅ 31 | - 200 square meters 32 | 33 | **6. Water is being pumped out , at a constant rate, from an underground storage tank that has a height 5 Meters. Which of the graphs below best represent the changes in the height of water in the tank as a function of the time (X axis - Time, Y axis - Height)?** 34 | 35 | 36 | - ✅ 37 | 38 | - 39 | 40 | - 41 | 42 | - 43 | 44 | 45 | **7. Rama drove at a constant speed for 2 hours. He then stopped for an hour to do some shopping and have a rest and then drove back home driving at a constant speed. Which graph best represents the changes in the distance from home as Rama was driving (X axis - Time, Y axis - Distance)?** 46 | 47 | - 48 | 49 | - ✅ 50 | 51 | - 52 | 53 | - 54 | 55 | **8. In a certain college, 40% of a class are taking Physics, 30% are taking calculus and 10% are taking both. If 40 students are enrolled in the class, how many students are taking neither Physics nor calculus?** 56 | - 12 57 | - 4 58 | - 8 59 | - 16 ✅ 60 | 61 | **9. The circumference of a circle inscribed inside a square with a side of 20 meters.** 62 | - 10π 63 | - 10√2π 64 | - 20π ✅ 65 | - 20√2π 66 | 67 | **10. Two different schools (A and B) have the same number of pupils. The ratio of the boys in school A and the boys in school B is 2:1 and the ratio of the girls in school A and the girls in school B is 4:5. Find the ratio of the boys in school A to the girls in school A.** 68 | - 1:4 69 | - 1:5 70 | - 2:5 71 | - 1:2 ✅ 72 | -------------------------------------------------------------------------------- /Week1/README.md: -------------------------------------------------------------------------------- 1 | # Week 1 Quiz 💡 2 | 3 | **1. A function calling itself with a smaller instance is called as________________** 4 | - Recursion ✅ 5 | - Self-calling function 6 | - Iteration 7 | - Smaller instance function 8 | 9 | **2. __________ option in Scratch is used to wait between the commands** 10 | - Events 11 | - Control ✅ 12 | - Sensing 13 | - Operators 14 | 15 | **3. Which of the following is the extension for a scratch file?** 16 | - sf 17 | - sh 18 | - sc 19 | - sb ✅ 20 | 21 | **4. The command to make sprite walk by certain steps is** 22 | - walk 23 | - move ✅ 24 | - ahead 25 | - forward 26 | 27 | **5. What is the action of next-costume command on sprite in Scratch?** 28 | - Changes color of sprite 29 | - Changes style of sprite ✅ 30 | - Moves sprite to different position 31 | - Shows animation of sprite 32 | 33 | **6. What is the output of the following** 34 | 35 | 36 | 37 | - 0 38 | - 100 39 | - 80 ✅ 40 | - 20 41 | 42 | **7. Which of the following is not a control command in Scratch?** 43 | - repeat 44 | - repeat until 45 | - forever 46 | - forever until ✅ 47 | 48 | **8. What one iteration of the following block of instructions represent?** 49 | 50 | 51 | 52 | - Sprite going vertically up by 10 steps 53 | - Sprite going backward by 10 steps ✅ 54 | - Sprite going forward by 10 55 | - Sprite remains in its place 56 | 57 | **9. The command used to make the Sprite disappear from the animation stage is** 58 | - Show 59 | - Vanish 60 | - Hide ✅ 61 | - Disappear 62 | 63 | **10. What is the output of the following code?** 64 | 65 | 66 | 67 | - Multiplication table of 2 ✅ 68 | - Power of 2 69 | - Factorial of x 70 | - None of the above 71 | -------------------------------------------------------------------------------- /Week10/README.md: -------------------------------------------------------------------------------- 1 | # Week 10 Quiz 💡 2 | 3 | **1. The game ”FLAMES” represents which of the following mathematics question?** 4 | - Josephus problem ✅ 5 | - Euclid’s problem 6 | - Euler’s problem 7 | - none of the above 8 | 9 | **2. Predict the output of the following code** 10 | 11 | 12 | 13 | - HELLO 14 | - Hello 15 | - hello 16 | - error ✅ 17 | 18 | **3. Predict the output of the following code** 19 | 20 | 21 | 22 | - Hellogoodmorning ✅ 23 | - Hello goodmorning 24 | - Hello good morning 25 | - error 26 | 27 | **4. What does the following code snippet in python print?** 28 | 29 | 30 | 31 | - der 32 | - ind 33 | - nde ✅ 34 | - de 35 | 36 | **5. In python, the default value of start and end index of list slicing are which of the following options?** 37 | - 1, length of the list 38 | - 0, length of the list ✅ 39 | - 0, length of the list -1 40 | - 1, length of the list -1 41 | 42 | **6. Which of the following is not a functionality of string in python?** 43 | - lower() 44 | - replace() 45 | - isalpha() 46 | - append() ✅ 47 | 48 | **7. Predict the output** 49 | 50 | 51 | 52 | - class ’numpy.2darray’ 53 | - int32 54 | - class ’numpy.ndarray’ ✅ 55 | - error 56 | 57 | **8. Which of the following code snippet will print transpose of the matrix a?** 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | ✅ 66 | 67 | **9. Which of the following will print column sum of the matrix a?** 68 | 69 | ✅ 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | **10. Image compression is always a lossy compression.** 78 | - True 79 | - False ✅ 80 | 81 | -------------------------------------------------------------------------------- /Week10/week 10 programming assignment 1.py: -------------------------------------------------------------------------------- 1 | a,b,c = int(input()),input().split(),0 2 | 3 | key = [b[i-a:i] for i in range(1,len(b)+1) if i % a == 0] 4 | 5 | for i in range(len(key)): 6 | 7 | if key[i].count('1') == 2: 8 | c = i+1 9 | 10 | if c!=0: 11 | print("yes",c,end="") 12 | 13 | else: 14 | print("no",end="") 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week10/week 10 programming assignment 2.py: -------------------------------------------------------------------------------- 1 | a,b,c,d = int(input()),input().split(),0,[] 2 | 3 | key = [b[i-a:i] for i in range(1, len(b) + 1) if i % a == 0] 4 | 5 | for i in range(a): 6 | l = [] 7 | 8 | for j in range(a): 9 | l.append(key[j][i]) 10 | d.append(l) 11 | 12 | for m in range(a): 13 | if d[m].count('1') == 2: 14 | c = m + 1 15 | 16 | if c!=0: 17 | print("yes",c,end="") 18 | 19 | else: 20 | print("no",end="") 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Week10/week 10 programming assignment 3.py: -------------------------------------------------------------------------------- 1 | a,b,c = int(input()),input().split(),0 2 | 3 | key = [b[i-a:i] for i in range(1, len(b)+1)if i%a==0 and b.count("0")!=a*a] 4 | 5 | for i in range(a): 6 | 7 | for j in range(a): 8 | 9 | if len(key) > 1 and key[i][j] == key[j][i]: 10 | 11 | c=c+1 12 | 13 | if c == a*a: 14 | print("yes",end="") 15 | 16 | else: 17 | print("no",end="") 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Week11/README.md: -------------------------------------------------------------------------------- 1 | # Week 11 Quiz 💡 2 | 3 | **1. The python library selenium is used for which of the following concepts** 4 | - File Handling 5 | - Image processing 6 | - Natural Language Processing 7 | - Browser automation ✅ 8 | 9 | **2. Which of the following is true about Browser automation?** 10 | - load and performance testing on the websites 11 | - web data extraction 12 | - automated testing 13 | - All of the above ✅ 14 | 15 | **3. The python function for converting a number into a string is** 16 | - numtostring() 17 | - str() ✅ 18 | - to_string() 19 | - numstring() 20 | 21 | **4. Which of the following is the python library for setting the timezone?** 22 | - pytimezone 23 | - pythonTimeZone 24 | - timezone 25 | - pytz ✅ 26 | 27 | **5. Which of the following code snippet will print today’s date?** 28 | 29 | - 30 | 31 | - 32 | 33 | - Both A and B ✅ 34 | - none 35 | 36 | **6. Predict the output:** 37 | 38 | 39 | 40 | - 41 | 42 | - ✅ 43 | 44 | - 45 | 46 | - Error 47 | 48 | **7. What does the following code print?** 49 | 50 | 51 | 52 | - Number of leapdays between the specified years ✅ 53 | - Lists all leapdays between the specified years 54 | - Lists the leapdays and its count between the specified years 55 | - None 56 | 57 | **8. What does the python function: calendar.weekday(year, month, day) return if the weekday is Friday?** 58 | - 3 59 | - 4 ✅ 60 | - 5 61 | - 6 62 | 63 | **9. What is the return value of the following python function : datetime.datetime.utcnow()** 64 | - returns the coordinated universal time ✅ 65 | - returns the current user time 66 | - returns the coordinated user time 67 | - returns the concurrent universal time 68 | 69 | **10. Which of the following is the correct code to find whether a given year is a leap year or not?** 70 | 71 | - 72 | 73 | - 74 | 75 | - ✅ 76 | 77 | - 78 | -------------------------------------------------------------------------------- /Week11/Week 11 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | # PYTHON program to count ways to write 2 | # number as sum of even integers 3 | # Initialize mod variable as constant 4 | 5 | MOD = 1e9 + 7 6 | 7 | # Iterative Function to calculate 8 | # (x^y)%p in O(log y) 9 | 10 | def power(x, y, p) : 11 | res = 1 # Initialize result 12 | 13 | x = x % p # Update x if it is more 14 | # than or equal to p 15 | 16 | while (y > 0) : 17 | 18 | # If y is odd, multiply x 19 | # with result 20 | 21 | if (y & 1) : 22 | res = (1 * res * x) % p 23 | 24 | # y must be even now 25 | 26 | y = y >> 1 # y = y/2 27 | x = (1 * x * x) % p 28 | 29 | 30 | return res 31 | 32 | 33 | # Return number of ways to write 'n' 34 | # as sum of even integers 35 | 36 | def countEvenWays(n) : 37 | 38 | return power(2, n//2 - 1, MOD) 39 | 40 | # Driver code 41 | 42 | n = int(input()) 43 | 44 | if n % 2==0: 45 | 46 | print(int(countEvenWays(n))) 47 | 48 | else: 49 | 50 | print("invalid") 51 | -------------------------------------------------------------------------------- /Week11/Week 11 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | # define punctuation 2 | 3 | punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' 4 | 5 | my_str = input() 6 | 7 | # To take input from the user 8 | # my_str = input("Enter a string: ") 9 | 10 | # remove punctuation from the string 11 | no_punct = "" 12 | 13 | for char in my_str: 14 | 15 | if char not in punctuations: 16 | 17 | no_punct = no_punct + char 18 | 19 | # display the unpunctuated string 20 | 21 | print(no_punct) -------------------------------------------------------------------------------- /Week11/Week 11 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def countStrings(n): 2 | 3 | a=[0 for i in range(n)] 4 | b=[0 for i in range(n)] 5 | a[0] = b[0] = 1 6 | for i in range(1,n): 7 | a[i] = a[i-1] + b[i-1] 8 | b[i] = a[i-1] 9 | 10 | return a[n-1] + b[n-1] 11 | 12 | # Driver program to test 13 | # above functions 14 | 15 | n = int(input()) 16 | 17 | if n>0: 18 | print(countStrings(n)) 19 | 20 | else: 21 | print("invalid") -------------------------------------------------------------------------------- /Week12/README.md: -------------------------------------------------------------------------------- 1 | # Week 12 Quiz 💡 2 | 3 | **1. Which of the following is true about the web graph used for performing Google page ranking?** 4 | - nodes are the hyperlinks and edges are the web pages 5 | - nodes are the web pages and edges are the hyperlinks ✅ 6 | - nodes and edges both represent hyperlinks 7 | - nodes and edges both represent web pages 8 | 9 | **2. In page ranking, the most impressive person is the person liked by maximum number of people.** 10 | - TRUE 11 | - FALSE ✅ 12 | 13 | **3. What is not true about page ranking algorithm?** 14 | - involves a random walk around the network 15 | - involves a drunkard walk around the network 16 | - high ranked node is the one with maximum visits 17 | - high ranked node is the one with maximum hyperlink ✅ 18 | 19 | **4. In page ranking algorithm** 20 | - we always begin ranking from the first node. 21 | - we randomly move from one node to another ✅ 22 | - we stop at the sink node 23 | - All the above statements are true 24 | 25 | **5. In Barbell graph() function of Networkx** 26 | - the first parameter represents number of communities and the second parameter represents number of nodes in-between the communities 27 | - the first parameter represents number of nodes in the two communities and the second parameter represents number of nodes in-between the communities ✅ 28 | - the first parameter represents number of nodes in-between the communities and the second parameter represents number of nodes in the two communities 29 | - the first parameter represents number of nodes in-between the communities and the second parameter represents number of communities 30 | 31 | **6. What is the type of the following graph?** 32 | 33 | 34 | 35 | - star graph 36 | - barbell graph 37 | - ladder graph ✅ 38 | - wheel graph 39 | 40 | **7. Which of the following graph represent a Wheel graph of 5 nodes?** 41 | 42 | - ✅ 43 | 44 | - 45 | 46 | - 47 | 48 | - 49 | 50 | **8. What is the next step in page ranking algorithm, if the current node in the walk is a sink ?** 51 | - the algorithm stops 52 | - the next node is selected randomly from the given set of nodes present in the graph 53 | - the next node is selected randomly from the list of neighbours of the current node ✅ 54 | - the algorithm restarts from the current node 55 | 56 | **9. Which of the following is a directed network?** 57 | - Social Networking 58 | - Supply Chain networks 59 | - Citation Network 60 | - All of the above ✅ 61 | 62 | **10. Which of the following python function will return random floating point number between 0 and 1?** 63 | - random.float() 64 | - random.randomfloat() 65 | - random.frandom() 66 | - random.random() ✅ 67 | -------------------------------------------------------------------------------- /Week12/Week 12 programming assignment 1.py: -------------------------------------------------------------------------------- 1 | import numpy as np # importing numpy module 2 | 3 | # taking endpoints from the user as point_1, point_2 & point_3 4 | 5 | point_1 = list(map(float,input().split())) 6 | point_2 = list(map(float,input().split())) 7 | point_3 = list(map(float,input().split())) 8 | 9 | arr = np.array([point_1,point_2,point_3]) 10 | 11 | volume = abs(np.linalg.det(arr)) 12 | 13 | final = float("{0:.1f}". format(volume)) 14 | 15 | print(final,end="") -------------------------------------------------------------------------------- /Week12/Week 12 programming assignment 2.py: -------------------------------------------------------------------------------- 1 | n = int(input()) #taking no. of question comes in Gate exam ferom the user 2 | 3 | ramesh_answer = input().split() 4 | 5 | suresh_answer = input().split() 6 | 7 | max_marks = 0 8 | 9 | for i in range(n): 10 | 11 | if ramesh_answer[i] not in suresh_answer[i] and suresh_answer[i] != "." and ramesh_answer[i] !=".": 12 | 13 | max_marks += 1 14 | print(max_marks, end="") -------------------------------------------------------------------------------- /Week12/Week 12 programming assignment 3.py: -------------------------------------------------------------------------------- 1 | # importing math modulw 2 | import math 3 | 4 | #taking length of side PQ 5 | PQ = int(input()) 6 | 7 | #taking length of side PR 8 | PR = int(input()) 9 | 10 | #finding length of side QR 11 | QR = (PQ * PQ + PR * PR) ** (0.5) 12 | 13 | #finding the angle XQR 14 | Angle_XQR = math.asin(PQ / QR) 15 | 16 | #rounding off the value to nearest integer 17 | print(round(math.degrees(Angle_XQR)),end="") -------------------------------------------------------------------------------- /Week2/README.md: -------------------------------------------------------------------------------- 1 | # Week 2 Quiz 💡 2 | 3 | **1. When we save a Python code it will be saved as file name with the extension?** 4 | - .p 5 | - .pyt 6 | - .python 7 | - .py ✅ 8 | 9 | **2. You are calculating the simple interest using a python program. How do you get the interest as an input from the user?** 10 | - r=float(input(”Enter the interest rate”)) ✅ 11 | - r=int(input(”Enter the interest rate”)) 12 | - r=input(”Enter the interest rate”) 13 | - None of these 14 | 15 | **3. Consider that you are developing a 2 player game in python. You have taken the names of both the users and stored them as variables user1 and user2. 16 | If you want to say Hi to both the users, print their names and welcome them to your game, which of the following statement(s) will fit to your requirement?** 17 | - print(”Hi”+user1+”and”+user2+”Welcome to the game”) ✅ 18 | - print(”Hi”,user1,”and”,user2,”Welcome to the game”) ✅ 19 | - print(”Hi”,”user1”,”and”,”user2”,”Welcome to the game”) 20 | - print(”Hi”+user1,”and”,user2+”Welcome to the game”) ✅ 21 | 22 | **4. What is the output of this code snippet ?** 23 | 24 | 25 | 26 | - numbers are equal ✅ 27 | - numbers are not equal 28 | 29 | **5. What does the following code snippet print?** 30 | 31 | 32 | 33 | - All numbers from 0 to 19 34 | - Pair of numbers from 0 to 19 whose difference is 2 35 | - All even numbers from 0 to 19 ✅ 36 | - All odd numbers from 0 to 19 37 | 38 | **6. What is the output of the code snippet given?** 39 | 40 | 41 | 42 | - 10 100 43 | - 10 90 44 | - An error will be generated 45 | - 10 10 ✅ 46 | 47 | **7. Given this code snippet,determine its output?** 48 | 49 | 50 | 51 | - 5040 ✅ 52 | - 4050 53 | - 504 54 | - 405 55 | 56 | **8. Consider the code snippet given, describe its output?** 57 | 58 | 59 | 60 | - Some 7 numbers 61 | - First 6 natural numbers 62 | - Next 6 Numbers after the input number a ✅ 63 | - Next 7 Numbers after the input number a 64 | 65 | **9. Consider the code snippet given, What might be the output of this?** 66 | 67 | 68 | 69 | - Decreasing order of natural numbers from 7 ✅ 70 | - Decreasing order of natural numbers from 8 71 | - Increasing order of natural numbers till 7 72 | - Increasing order of natural numbers till 8 73 | 74 | **10. Which of the following is not a valid variable name?** 75 | 76 | - var-1 ✅ 77 | - var1 78 | - Var1 79 | - var 1 ✅ 80 | -------------------------------------------------------------------------------- /Week2/Week 2 programming assignment 1.py: -------------------------------------------------------------------------------- 1 | number = int(input()) 2 | print(number) -------------------------------------------------------------------------------- /Week2/Week 2 programming assignment 2.py: -------------------------------------------------------------------------------- 1 | a,b = map(int, input().split()) 2 | print(a*b) -------------------------------------------------------------------------------- /Week2/Week 2 programming assignment 3.py: -------------------------------------------------------------------------------- 1 | a,b = map(int, input().split()) 2 | if a>b: 3 | print(a) 4 | else: 5 | print(b) -------------------------------------------------------------------------------- /Week3/New Week 3 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | n=input() 2 | 3 | k = input() 4 | 5 | res = list() 6 | 7 | lst1=list() 8 | 9 | lst1 = k.split(" ") 10 | 11 | for i in lst1: 12 | 13 | if i not in res: 14 | 15 | res.append(i) 16 | 17 | for j in range(0,len(res)): 18 | 19 | if j!=len(res)-1: 20 | 21 | print(res[j],end=" ") 22 | 23 | else: 24 | 25 | print(res[j],end="") -------------------------------------------------------------------------------- /Week3/README.md: -------------------------------------------------------------------------------- 1 | # Week 3 Quiz 💡 2 | 3 | **1. What is the output of the following code?** 4 | 5 | 6 | 7 | - ✅ 8 | 9 | - 10 | 11 | - 12 | 13 | - 14 | 15 | **2. Consider the list L= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34].What will be output of the statement L [3:6]?** 16 | - [2, 3, 5] ✅ 17 | - [0, 1, 1] 18 | - [1, 2, 3] 19 | - none 20 | 21 | **3. Which of the following is the method to insert an item into a specified position in a list?** 22 | - Append 23 | - Insert ✅ 24 | - Add 25 | - InsertAt 26 | 27 | **4. ___________ method returns the number of occurrences of an element in a list.** 28 | - NumberOf 29 | - Total 30 | - Count ✅ 31 | - Length 32 | 33 | **5. In the game FizzBuzz, what should be the output for the number 510?** 34 | - Fizz 35 | - Buzz 36 | - FizzBuzz ✅ 37 | - Either A or B 38 | 39 | **6. Which of the following trims the list L by 10%** 40 | - Stats.trim_mean(L, 10) 41 | - Stats.trim_mean(L, 0.1) ✅ 42 | - Stats.trim_mean(L, -10) 43 | - Stats.trim_mean(L, -0.1) 44 | 45 | **7. Which of the following code is invalid?** 46 | 47 | - import matplotlib.pyplot as plt\ 48 | plt.plot([1,2,3,4],[1,3,6,9],'b+') 49 | 50 | - import matplotlib.pyplot as plt\ 51 | plt.plot([1,2,3,4],[1,3,6,9],'b++') ✅ 52 | 53 | - import matplotlib.pyplot as plt\ 54 | plt.plot([1,2,3,4],[1,3,6,9],'b*') 55 | 56 | - import matplotlib.pyplot as plt\ 57 | plt.plot([1,2,3,4],[1,3,6,9],'b--') 58 | 59 | **8. In how many different ways can you arrange the letters in the word COMP?** 60 | - 24 ✅ 61 | - 4 62 | - 6 63 | - 20 64 | 65 | **9. The method open(“file1.txt”, r+) opens the file file1.txt in** 66 | - Read mode 67 | - Write mode 68 | - Read write mode ✅ 69 | - Append mode 70 | 71 | **10. The function random.randint(1,100) in python generates** 72 | - A random integer between 1 to 100 with 1 and 100 both inclusive ✅ 73 | - A random integer between 1 to 100 with 1 and 100 both exclusive 74 | - A random integer between 1 to 100 with only 100 inclusive 75 | - None of the above 76 | -------------------------------------------------------------------------------- /Week3/Week 3 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | arr = input().split(" ") 2 | 3 | res = [] 4 | 5 | new = [] 6 | 7 | for i in range(len(arr)): 8 | 9 | if arr[i].endswith("4"): 10 | res.append(arr[i]) 11 | 12 | else: 13 | new.append(arr[i]) 14 | 15 | 16 | listToStr = ' '.join([str(elem) for elem in new]) 17 | 18 | print(listToStr) 19 | 20 | -------------------------------------------------------------------------------- /Week3/Week 3 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | a = [int(x) for x in input().split()] 2 | 3 | a.sort() #this command sorts the list in ascending order 4 | 5 | if a[-2]==a[-1]: 6 | print(a[-3]+a[1]) 7 | 8 | 9 | else: 10 | print(a[-2] + a[1]) 11 | -------------------------------------------------------------------------------- /Week3/Week 3 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | a = [int(x) for x in input().split()] 2 | 3 | res = [] 4 | 5 | for i in a: 6 | if i not in res: 7 | res.append(i) 8 | 9 | listToStr = ' '.join([str(elem) for elem in res]) 10 | 11 | print(listToStr) -------------------------------------------------------------------------------- /Week4/README.md: -------------------------------------------------------------------------------- 1 | # Week 4 Quiz 💡 2 | 3 | 4 | **1. A magic square is an n ×n matrix in which** 5 | - Sum of numbers in each row is same 6 | - Sum of numbers in each column is same 7 | - Sum of numbers in each diagonal is same 8 | - All of the above ✅ 9 | 10 | **2. For any magic square of n × n, the magic number M is given by** 11 | - n (n^2 + 1) / 2 ✅ 12 | - n (n + 1) / 2 13 | - (n^2 + 1) / 2 14 | - (n + 1) / 2 15 | 16 | **3. Assuming that num is always a 2-digit number, what is the output of the following code?** 17 | 18 | 19 | 20 | - Prints the number if the sum of squares of its digits is the number itself 21 | - Prints the number if the sum its digits is the number itself 22 | - Prints the number if the product of its digits is the number itself 23 | - Prints nothing ✅ 24 | 25 | 26 | **4. In a double game each pair of cards will have** 27 | - Only two symbols in common 28 | - Only one symbol in common ✅ 29 | - All symbols in common 30 | - No symbols in common 31 | 32 | 33 | **5. The minimum number of people required to guarantee that at least two people will have their birthdays falling on the same day of a 34 | non-leap year is..** 35 | - 365 36 | - 364 37 | - 366 ✅ 38 | - 367 39 | 40 | **6. What does the following code snippet in python compute?** 41 | 42 | num = int(input()) 43 | for i in range(1, 11): 44 | print(num*i) 45 | 46 | - Factorial of num 47 | - Multiplication table of num ✅ 48 | - Powers of num 49 | - None 50 | 51 | 52 | **7. Which of the following will print all prime numbers in an interval?** 53 | 54 | - ✅ 55 | 56 | - 57 | 58 | - 59 | 60 | - 61 | 62 | 63 | **8. Which of the following method in python choses a movie from the list of movie names given below?** 64 | 65 | movies =["zindagi" , " chinatown " , "darr" , " 3idiots " , "sixthsense" , "speed" , "avtaar"] 66 | 67 | - random.random(movies) 68 | - random.choice(movies) ✅ 69 | - random.select(movies) 70 | - All of the above 71 | 72 | **9. In “Guess the Movie Name” game, at-most how many guesses do you need to make for a five lettered movie name with all distinct letters in it?** 73 | - 53,130 ✅ 74 | - 6,37,5600 75 | - 120 76 | - 5 77 | 78 | 79 | **10. In “Guess the movie name” game, if the player asks to open up a letter that is not present in the actual movie name then the closest letter that precedes this requested letter in the alphabetical order and present in the actual movie name is opened up** 80 | - True 81 | - False ✅ 82 | -------------------------------------------------------------------------------- /Week4/Week 4 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | def arrange_number(a, b): 2 | 3 | if a>b: 4 | 5 | s=b 6 | 7 | else: 8 | 9 | s=a 10 | 11 | for i in range(1, s+1): 12 | 13 | if a%i==0 and b%i==0: 14 | 15 | result=i 16 | 17 | return result 18 | 19 | 20 | 21 | m=int(input()) 22 | 23 | n=int(input()) 24 | 25 | print(arrange_number(m,n)) 26 | 27 | -------------------------------------------------------------------------------- /Week4/Week 4 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def fact(num): 2 | 3 | product=1 4 | 5 | while(num>1): 6 | 7 | product*=num 8 | 9 | num-=1 10 | 11 | return product 12 | 13 | m=int(input()) #m=men 14 | 15 | n=int(input()) #n=women 16 | 17 | if m+n>20 or m<=n: 18 | 19 | print('invalid',end="") 20 | 21 | else: 22 | 23 | print(fact(m)*fact(n)*fact(m+1)//(fact(n)*fact(m+1-n)),end="") -------------------------------------------------------------------------------- /Week4/Week 4 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | n =int(input()) 2 | 3 | count = 1 4 | 5 | for i in range(1, n+1): 6 | 7 | for j in range(1, i+1): 8 | 9 | print(count*count, end=" ") 10 | 11 | count+=1 12 | 13 | print() 14 | -------------------------------------------------------------------------------- /Week5/README.md: -------------------------------------------------------------------------------- 1 | # Week 5 Quiz 💡 2 | 3 | 4 | **1. Let marks scored be a dictionary of the items given below:-** 5 | 6 | marks_scored = { }\ 7 | marks_scored[’maths’]= 80\ 8 | marks_scored[’science’]=90\ 9 | marks_scored[’english’]=85\ 10 | marks_scored[’social’]=95 11 | 12 | 13 | **Which of the following operation will print the items of the dictionary?** 14 | - marks_scored.items() ✅ 15 | - marks_scored.keys() 16 | - marks_scored.values() 17 | - all of the above 18 | 19 | 20 | **2. Which of the following operation on the dictionary marks_scored in Question 1 will remove a specified key and return the corresponding value?** 21 | - marks_scored.remove 22 | - marks_scored.del 23 | - marks_scored.pop ✅ 24 | - marks_scored.popitem 25 | 26 | **3. Speech recognition does not work on .wav extension files** 27 | - True 28 | - False ✅ 29 | 30 | 31 | **4. What are the items in the following dictionary :** 32 | 33 | Dictionary = {x: x*x for x in range(11) if x % 2 == 0 }\ 34 | print(Dictionary) 35 | 36 | - Dictionary of odd numbers and their squares 37 | - Dictionary of even numbers and their squares ✅ 38 | - dictionary of numbers divisible by 2 39 | - non of the above 40 | 41 | **5. In the game ”Rock, Paper and Scissor”, if player one enters 456 and player two enters 684 with their secret bits 0 and 2 respectively, then the expected outcome of the game would be ______** 42 | - Player one wins 43 | - Player two wins 44 | - draw 45 | - insufficient data ✅ 46 | 47 | **6. What is the output of the following code:** 48 | 49 | 50 | 51 | - Ajay\ 52 | sem : 3\ 53 | roll_no : 1\ 54 | total_marks : 85\ 55 | Shwetha\ 56 | sem : 3\ 57 | roll_no : 2\ 58 | total_marks : 90 ✅ 59 | 60 | - Ajay, sem : 3,roll_no : 1, total_marks : 85\ 61 | Shwetha, sem : 3, roll_no : 2, total_marks : 90 62 | 63 | - { Ajay, sem : 3,roll_no : 1, total_marks : 85 , Shwetha, sem : 3,\ 64 | roll_no : 2, total_marks : 90 } 65 | - none of the above 66 | 67 | **7. Binary search can be applied on any list of random elements** 68 | - True 69 | - False ✅ 70 | 71 | **8. Which of the following is true about bubble sort?** 72 | - In each iteration the first element in unsorted list is compared with the remaining elements 73 | - The algorithm stops when the list is already sorted 74 | - In each iteration every consecutive pairs of the unsorted list are compared ✅ 75 | - There is swapping of elements in each comparison made 76 | 77 | 78 | **9. Which are the given statements precisely explains the action of the given code?** 79 | 80 | 81 | 82 | - rolls the dices as long as the input is ’y’ 83 | - rolls the dices until the sum of their face values is 12 84 | - rolls the dices as long as the input is ’y’ or the sum of their face values is 12 ✅ 85 | - rolls the dices infinitely 86 | 87 | **10. What will be the output of the following code?** 88 | 89 | 90 | 91 | - 3 2 92 | - 2 3 93 | - 2 3 01 ✅ 94 | - 01 3 2 95 | -------------------------------------------------------------------------------- /Week5/Week 5 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for num in range(1, n + 1): 3 | for i in range(num): 4 | print (num, end = "") #printing number 5 | print() -------------------------------------------------------------------------------- /Week5/Week 5 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | arr=input().split() 2 | 3 | swap=0 4 | 5 | for i in range(len(arr)): 6 | 7 | for j in range(i+1,len(arr)): 8 | 9 | if(int(arr[i])>int(arr[j])): 10 | 11 | temp=arr[i] 12 | 13 | arr[i]=arr[j] 14 | 15 | arr[j]=temp 16 | 17 | swap = swap+1 18 | 19 | print(swap,end="") 20 | -------------------------------------------------------------------------------- /Week5/Week 5 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | num=input().split() 2 | 3 | n =int(input()) 4 | 5 | l = [] 6 | for i in num: 7 | l.append(int(i)) 8 | 9 | max = sorted(l, reverse=True) 10 | 11 | min = sorted(l) 12 | 13 | max_num = [] 14 | 15 | min_num = [] 16 | 17 | for j in max: 18 | if j not in max_num: 19 | 20 | max_num.append(j) 21 | 22 | for k in min: 23 | if k not in min_num: 24 | 25 | min_num.append(k) 26 | 27 | result = max_num[n-1]+min_num[n-1] 28 | print(result, end="") 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Week6/README.md: -------------------------------------------------------------------------------- 1 | # Week 6 Quiz 💡 2 | 3 | 4 | **1. In Caesar cipher,the mediator needs to make maximum of how many trails to break the code?** 5 | - 1 6 | - 26 ✅ 7 | - no trail needed 8 | - 10 9 | 10 | 11 | 12 | **2. What is the result of the following code if the input is COMPUTING?** 13 | 14 | 15 | 16 | - FRPSXWLQJ 17 | - HTRUZYNSL 18 | - GSQTYXMRK ✅ 19 | - none of the above 20 | 21 | 22 | **3. Which of the following is TRUE about MIN-MAX strategy?** 23 | - Maximise the chances of your winning and minimize the changes of the opponent winning ✅ 24 | - The game with min-max strategy can never be drawn 25 | - minimise the chances of your winning and maximize the chances of the opponent winning 26 | - All the above are true 27 | 28 | **4. What is the output of the following code?** 29 | 30 | 31 | 32 | - Greatest common factor of num1 and num2 ✅ 33 | - Least common factor of num1 and num2 34 | - Least common multiple of num1 and num2 35 | - Greatest common multiple of num1 and num2 36 | 37 | **5. What does the following python code compute?** 38 | 39 | 40 | 41 | - power of a raised to b 42 | - sum of a and b 43 | - product of a and b ✅ 44 | - none of the above 45 | 46 | **6. Which of the following is not true about recursion?** 47 | - The speed of a program using recursion is same as that of the speed of its non-recursive equivalent 48 | - The speed of a program using recursion is slower than the speed of its non-recursive equivalent 49 | - The speed of a program using recursion is faster than the speed of its non-recursive equivalent ✅ 50 | - Recursive programs are easier to understand and code than that of its non-recursive equivalent 51 | 52 | **7. Which of the following is the optimal code among the given codes using recursive binary search?** 53 | 54 | 55 | 56 | ✅ 57 | 58 | 59 | 60 | 61 | 62 | **8. What is the result of the following recursive function call?** 63 | 64 | 65 | 66 | - 2 ✅ 67 | 68 | 6 69 | 70 | 24 71 | 72 | - 1 73 | 74 | 2 75 | 76 | 6 77 | 78 | 24 79 | 80 | - 2 81 | 82 | 4 83 | 84 | 12 85 | 86 | - 1 87 | 88 | 2 89 | 90 | 4 91 | 92 | 12 93 | 94 | **9. What is the output of the following python code?** 95 | 96 | 97 | 98 | - 24 99 | - Runs infinitely 100 | - Recursion error ✅ 101 | - 1 102 | 103 | **10. A program can be written using recursive function only if it can be recursively defined.** 104 | - TRUE 105 | - FALSE ✅ 106 | -------------------------------------------------------------------------------- /Week6/Weeek 6 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | for i in range(1, int(input()) + 1): 2 | 3 | print(int((10 ** i - 1) / 9) ** 2) 4 | -------------------------------------------------------------------------------- /Week6/Weeek 6 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | str_1 = input() 2 | 3 | str_2 = input() 4 | 5 | sorted_str1 = [] 6 | 7 | sorted_str2 = [] 8 | 9 | k = sorted(str_1.upper()) 10 | 11 | l = sorted(str_2.upper()) 12 | 13 | for i in k: 14 | if i.isalnum(): 15 | sorted_str1.append(i) 16 | 17 | for j in l: 18 | if j.isalnum(): 19 | sorted_str2.append(j) 20 | 21 | if sorted_str1 == sorted_str2: 22 | print("Yes") 23 | else: 24 | print("No") 25 | -------------------------------------------------------------------------------- /Week6/Weeek 6 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | shift = 3 # defining the shift count 2 | 3 | encrypted_text = input() 4 | 5 | plain_text = "" 6 | 7 | for c in encrypted_text: 8 | 9 | # check if character is an uppercase letter 10 | if c.isupper(): 11 | 12 | # find the position in 0-25 13 | c_unicode = ord(c) 14 | 15 | c_index = ord(c) - ord("A") 16 | 17 | # perform the negative shift 18 | new_index = (c_index - shift) % 26 19 | 20 | # convert to new character 21 | new_unicode = new_index + ord("A") 22 | 23 | new_character = chr(new_unicode) 24 | 25 | # append to plain string 26 | plain_text = plain_text + new_character 27 | 28 | else: 29 | 30 | # since character is not uppercase, leave it as it is 31 | plain_text += c 32 | 33 | 34 | print(plain_text[::-1]) -------------------------------------------------------------------------------- /Week7/README.md: -------------------------------------------------------------------------------- 1 | # Week 7 Quiz 💡 2 | 3 | **1. Which of the following is/are uses of functions?** 4 | - Gives higher level overview of the task to be performed 5 | - Reusability- use same functionality at various places 6 | - Better understanding of the code 7 | - All of the above ✅ 8 | 9 | **2. In Snakes and Ladders game the least number of times a player has to roll a die with the following ladder positions is _____________ 10 | ladders = { 3: 20, 6: 14, 11: 28, 15: 34, 17: 74, 22: 37, 38: 59, 49: 67, 57: 76, 61: 78, 73: 86, 81: 98, 88: 91 }** 11 | - 4 12 | - 5 ✅ 13 | - 6 14 | - 7 15 | 16 | **3. Which of the following is the end point of the game Snakes and Ladder?** 17 | - A player has reached the end point 18 | - A player quits the game 19 | - both A and B are the possibilities of the game to end ✅ 20 | - None of the above 21 | 22 | **4. What is the output of the following spiralprint python function?** 23 | 24 | 25 | 26 | - 1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11 27 | - 1 2 3 4 5 6 12 18 17 16 15 14 13 ✅ 28 | - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 29 | - 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 30 | 31 | **5. Which of the following code snippet will draw a star?** 32 | 33 | - 34 | 35 | - ✅ 36 | 37 | - 38 | 39 | - 40 | 41 | **6. Which of the following code snippet will draw a Hexagon?** 42 | 43 | - 44 | 45 | - 46 | 47 | - 48 | 49 | - ✅ 50 | 51 | **7. What is the output of the following code?** 52 | 53 | 54 | 55 | - ✅ 56 | 57 | - 58 | 59 | - 60 | 61 | - 62 | 63 | **8. In a file with extension csv what does csv mean?** 64 | - carry separated value 65 | - common sector value 66 | - class separated value 67 | - comma separated value ✅ 68 | 69 | **9. which of the following library has to be imported to plot the route map using GPS locations in python?** 70 | - csv 71 | - gmplot 72 | - both ✅ 73 | - none 74 | 75 | **10. Which of the following library moves the turtle backward?** 76 | - turtle.back(distance) 77 | - turtle.bk(distance) 78 | - turtle.backward(distance) 79 | - All of the above ✅ 80 | -------------------------------------------------------------------------------- /Week7/Week 7 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | k = input().split(" ") 2 | 3 | j = input().split(" ") 4 | 5 | if j[0] == k[0]: 6 | 7 | print("Yes") 8 | 9 | else: 10 | 11 | print("No") -------------------------------------------------------------------------------- /Week7/Week 7 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | num = input() 2 | 3 | k = num.split(",") 4 | 5 | m = 0 6 | 7 | n = 0 8 | 9 | for i in k: 10 | 11 | j= i.split(': ') 12 | 13 | if(int(j[0])> int(j[1])): 14 | 15 | m+=1 16 | 17 | if(int(j[1])> int(j[0])): 18 | 19 | n+=1 20 | 21 | print(m, end="") 22 | 23 | print(" ",end="") 24 | 25 | print(n, end="") -------------------------------------------------------------------------------- /Week7/Week 7 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | r = input() 2 | 3 | s = input() 4 | 5 | a = r.split(",") 6 | 7 | b = s.split(",") 8 | 9 | count = 0 10 | 11 | k = 0 12 | 13 | for i in range(len(b)): 14 | 15 | count = count + int(b[k]) 16 | 17 | k += 1 18 | 19 | for j in a: 20 | 21 | n = j.split(":") 22 | 23 | if count == int(n[0]): 24 | 25 | count = int(n[1]) 26 | 27 | if count>= 100: 28 | 29 | print("Yes", end="") 30 | 31 | else: 32 | 33 | print("No", end="") 34 | -------------------------------------------------------------------------------- /Week8/README.md: -------------------------------------------------------------------------------- 1 | # Week 8 Quiz 💡 2 | 3 | **1. Which of the following code snippet will create a tuple in python?** 4 | - name = (’kiran’,’bhushan’,’madan’) ✅ 5 | - name = {’kiran’,’bhushan’,’madan’} 6 | - name = [’kiran’,’bhushan’,’madan’] 7 | - All of the above 8 | 9 | **2.Which of the following is not true about tuples in python?** 10 | - Tuple consumes less memory 11 | - Tuples are immutable 12 | - Tuple supports item deletion ✅ 13 | - Tuples does not support modification 14 | 15 | **3. What is the output of the following code snippet in python?**\ 16 | name =(’kiran’,’bhushan’,’madan’)\ 17 | print (name[-1]) 18 | - invalid syntax 19 | - tuple index out of range 20 | - prints nothing 21 | - madan ✅ 22 | 23 | **4. What is the output of the following code?** 24 | 25 | 26 | 27 | - the program stops when the number entered matches with the random number generated ✅ 28 | - the program stops after certain number of trials 29 | - the program never stops 30 | - error 31 | 32 | **5. What does the following program plot?** 33 | 34 | 35 | 36 | - Plots the random number generated in each iteration 37 | - Plots the number of times the given input matches with the random number generated ✅ 38 | - Plots the input entered for each iteration 39 | - none of the above 40 | 41 | **6. In image processing using python what is the acronym of PIL?** 42 | - Python Interactive Library 43 | - Pillow Library 44 | - Python Image Library 45 | - Python Imaging Library ✅ 46 | 47 | **7. What does the following code snippet in python compute?** 48 | 49 | 50 | 51 | - checks whether the two given texts are same 52 | - searches for text2 in text1 53 | - finds all the occurrences of text2 in text1 ✅ 54 | - none of the above 55 | 56 | **8. Which of the following code will convert the uppercase letters of the given string into lower case and prints the converted string?** 57 | 58 | - ✅ 59 | 60 | - 61 | 62 | - both A and B 63 | - none 64 | 65 | **9. Which of the following is the platform for building Python programs to work with sentiment analysis of human language data?** 66 | - NLTK: Neutral Language Toolkit 67 | - NLTK: Natural Language Toolkit ✅ 68 | - NLTK: Normal Language Toolkit 69 | - NLTK: Natural Lingual Toolkit 70 | 71 | **10. Sentiment analysis involves working with whether ___________** 72 | - a piece of information is biased or unbiased 73 | - a piece of information is useful or not 74 | - a piece of information is true or false 75 | - a piece of information is positive or negative ✅ 76 | -------------------------------------------------------------------------------- /Week8/Week 8 Programming Assignment 1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | m,n = input().split() 3 | for i in range(int(m)): 4 | for k in [int(j) for j in input().split()]: 5 | if k!=0 and k!=1: 6 | print("No",end="") 7 | sys.exit() 8 | 9 | else: 10 | print("Yes",end="") 11 | -------------------------------------------------------------------------------- /Week8/Week 8 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | l =[] 2 | for i in range(int(input())): 3 | l.append([int(j) for j in input().split()]) 4 | k=[list(i) for i in zip(*l)] 5 | print("Yes",end="") if (k==l) else print("No",end="") -------------------------------------------------------------------------------- /Week8/Week 8 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | R = int(input()) 2 | 3 | print('\n'.join(' '.join(str(R*row + col) for col in range(1, R+1)) for row in range(R)), end='') -------------------------------------------------------------------------------- /Week9/README.md: -------------------------------------------------------------------------------- 1 | # Week 9 Quiz 💡 2 | 3 | **1. Which of the following is not true about Stylometry Analysis?** 4 | - It is quantitative study of literature style 5 | - It is based on the observation that the authors tend to write in relatively consistent and recognisable ways 6 | - any two people may have same vocabulary ✅ 7 | - It is a tool to study variety of questions involving style of writing 8 | 9 | **2. An author’s stylic signature can be analysed by which of the following method(s)?** 10 | - Plot a graph of word length distribution 11 | - Kilgariff’s Chi Squared method 12 | - John Burrow’s Delta method 13 | - All of the above ✅ 14 | 15 | **3. What is the output of the following code?** 16 | 17 | 18 | 19 | - ['Have nice day, my friend!!! Programming in Python is fun'] 20 | - ['Have nice day, my friend!!!', 'Programming in Python is fun'] ✅ 21 | - 'Have nice day, my friend!!!'\ 22 | 'Programming in Python is fun' 23 | - error 24 | 25 | **4. What is the output of the following code?** 26 | 27 | 28 | 29 | - 30 | 31 | - 32 | 33 | - ✅ 34 | 35 | - none of the above 36 | 37 | **5. Strings in python can be created using** 38 | - single quotes 39 | - double quotes 40 | - triple quotes 41 | - only A and B 42 | - A, B and C ✅ 43 | 44 | **6. Networkx in python is used for which of the following operation(s)?** 45 | - Visualizing social network 46 | - Analyzing social network 47 | - Generate social network 48 | - All of the above ✅ 49 | 50 | **7. Which of the following will generate a complete graph in python using Networkx package?** 51 | - Graph = nx.gnp random graph(25,0.5) 52 | - Graph = nx.gnp random graph(25,1.0) ✅ 53 | - Graph = nx.gnp random graph(25,0.25) 54 | - Graph = nx.gnp random graph(25,0.75) 55 | 56 | **8. Degree of separation of a complete graph with n nodes is always** 57 | - n 58 | - n-1 59 | - 1 ✅ 60 | - 6 61 | 62 | **9. Which of the following is true about six degrees of seperation?** 63 | - the minimum degree of separation of any node in the network is 6 64 | - the maximum degree of separation of any node in the network is 6 65 | - the average degree of separation of the nodes in the network is 6 ✅ 66 | - the degree of separation of every node in the network is 6 67 | 68 | **10. Which of the following method will return the RBG value of a pixel in python?** 69 | - getpixel() ✅ 70 | - RBGvalue() 71 | - pixelValue() 72 | - none of the above 73 | 74 | -------------------------------------------------------------------------------- /Week9/Week 9 Programming Assignment 2.py: -------------------------------------------------------------------------------- 1 | def checkPangram(s): 2 | List = [] 3 | # create list of 26 charecters and set false each entry 4 | for i in range(26): 5 | List.append(False) 6 | 7 | # converting the sentence to lowercase and iterating 8 | # over the sentence 9 | for c in s.lower(): 10 | if not c == " ": 11 | 12 | # make the corresponding entry True 13 | List[ord(c) -ord('a')]= True 14 | 15 | # check if any charecter is missing then return False 16 | for ch in List: 17 | if ch == False: 18 | return False 19 | return True 20 | 21 | # Driver Program to test above functions 22 | sentence = input() 23 | 24 | if (checkPangram(sentence)): 25 | print("Yes") 26 | else: 27 | print("No") -------------------------------------------------------------------------------- /Week9/Week 9 Programming Assignment 3.py: -------------------------------------------------------------------------------- 1 | def anti_vowel(text): 2 | for i in "aeiouAEIOU": 3 | text = text.replace(i,"") 4 | return text 5 | 6 | 7 | print(anti_vowel(input())) -------------------------------------------------------------------------------- /Week9/Week 9 Programming Assignment1.py: -------------------------------------------------------------------------------- 1 | # Python3 implementation to 2 | # find first element 3 | # occurring k times 4 | 5 | # function to find the 6 | # first element occurring 7 | # k number of times 8 | def firstElement(arr, n, k): 9 | 10 | # dictionary to count 11 | # occurrences of 12 | # each element 13 | count_map = {}; 14 | for i in range(0, n): 15 | if(arr[i] in count_map.keys()): 16 | count_map[arr[i]] += 1 17 | else: 18 | count_map[arr[i]] = 1 19 | i += 1 20 | 21 | for i in range(0, n): 22 | 23 | # if count of element == k , 24 | # then it is the required 25 | # first element 26 | if (count_map[arr[i]] == k): 27 | return arr[i] 28 | i += 1 29 | 30 | 31 | # Driver Code 32 | if __name__=="__main__": 33 | 34 | arr = input().split(" ") 35 | n = len(arr) 36 | k = int(input()) 37 | print(firstElement(arr, n, k)) --------------------------------------------------------------------------------