Posts

The joy of computing using Python Week - 9

Quiz Week 9 : Assignment 9 1. ‘nltk.download()‘ function downloads necessary packages for the Natural Language Toolkit (NLTK) library? True False 2. Which of the following best defines a complete graph? A graph where every pair of distinct vertices is connected by a unique edge A graph with no edges A graph with a single vertex A graph with at least one loop 3. How many edges are there in a complete graph with 4 nodes? 6 8 12 16 4. Which Python library is most commonly used for working with graphs related to networks? Random Pandas NumPy NetworkX 5. Gephi is: A Python library for linear algebra A software for visualizing and analyzing large networks A tool for data cleaning and preprocessing A Python library for building statistical models ...

Programming Assignment - 8

Programming Assignment - Week 8 Note: There could be optimised ways to solve the problem, but the goal here is to solve it effectively. The most intuitive solution has been provided for clarity. Programming Assignment 1 Question: Write a Python function that takes an integer n followed by n lines of space-separated integers, where each line represents a tuple. The function should return the sum of the first elements of all tuples. Input Format: The first line contains a single integer n , which represents the number of tuples. The next n lines each contain two space-separated integers representing the values of the tuple. Output Format: A single integer representing the sum of the first elements of all tuples. Example: Input: 3 3 4 1 2 5 6 Output: 9 Code: def sum_of_first_elements (): # Read the number of tuples n = int ( input ()) # Initialize the sum ...

The joy of computing using Python Week - 8

Quiz Week 8: Assignment 8 1. Which of the following is a valid way to create a tuple in Python? t = [1, 2, 3] t = (1, 2, 3) t = {1, 2, 3} t = 1, 2, 3 2. Which of the following operations is valid on a tuple? t[1] = 4 t.append(4) t = t + (4,) del t[1] 3. What will the following code output? t = [1, 2, 3] print(type((t, t))) <class 'list'> <class 'set'> <class 'tuple'> Error 4. What is the primary purpose of the matplotlib.pyplot module in Python? To perform matrix operations. To handle file I/O operations. To generate and customize visualizations like plots and graphs. To manipulate and process images. 5. Which of the following statements is true about anagrams? Two strings of different lengths can be anagra...

Programming Assignment - 7

Programming Assignment - Week 7 Note: There could be optimised ways to solve the problem, but the goal here is to solve it effectively. The most intuitive solution has been provided for clarity. Week 7: Programming Assignment 1 Question: You are given a board game scenario with ladders and snakes. A player starts at a given position on the board, and you are provided with the result of a die roll. You need to determine whether the player lands on a ladder, a snake, or a normal block after moving. Write a Python function named move_player that takes four inputs: ladders : A list containing the indices of blocks with ladders. snakes : A list containing the indices of blocks with snakes. current_position : An integer representing the player's current position on the board. die_roll : An integer representing the result of a die roll. The function should return...

The Joy of Computing using Python Week-7

Quiz Week 7: Assignment 7 1. Which of the following methods is used to read the content of a CSV file in Python using the csv module? csv.reader() csv.write() csv.load() csv.readfile() 2. Which command is used to install a Python package using pip? pip install package-name install pip package-name python install package-name pip package-name install 3. What is the primary purpose of the gmplot library in Python? To create 3D plots To plot data on Google Maps To generate matplotlib graphs To create dashboards 4. In a game of Snakes and Ladders, a player is currently on square 96. There is a snake on square 99 that sends the player back to square 78. If the player wishes to reach square 100 in one dice t...

Programming assignment - Week 6

Programming assignment - Week 6  Solutions Note: There could be optimised ways to solve the problem, but the goal here is to solve it effectively. The most intuitive solution has been provided for clarity.

The Joy of Computing using Python Week-6

Quiz Week 6: Assignment 6 Solution