Posts

Python NumPy Mini Projects: COVID Data Analysis

               This project deals with COVID Data analysis. COVID has huge impact in the society. It affects the humans around the world. Let us analyse the data. Code Implementation:               This program creates an array of countries. There are three arrays for covid confirmed, covid recovered and those who not survived(death). Calculate the details like total confirmed,total recovered and total death by adding the array elements. Recovery rate is calculated by the below formula, recovery_rate = (recovered / confirmed) * 100. Death rate is calculated by the formula given below, death_rate = (deaths / confirmed) * 100 Maximum Cases are found using max() function. The active cases are also calculated by the formula given here. Active case = Confirmed - Recovered - Deaths Daily cases, Average cases, Maximum and minimum cases are printed using built-in functions. Finally, al...

Python NumPy Mini Projects: Population Statistics dashboard

                 This project implements the Population Statistics Dashboard using NumPy. It shows the analysis of population in various countries and visualise the data. Let us implement the program. Implementation: First, include the NumPy Library. Add the countries and population details into separate arrays. Let us find the total population, average population, minimum population and maximum population using built-in functions. Least and most populated countries are identified using functions. Next. Population percentage and Population share of each country are calculated. Standard deviation and variance values are calculated. Finally, the countries are sorted according to the population. At last, the Population statistics dashboard was printed. Code: import numpy as np countries = np.array([     "India",     "China",     "USA",     "Brazil", ...

Python NumPy Mini projects: Election Vote Counter

              This is the mini project deals with Election Vote Counter. This project has candidate’s list. Voter has to select the candidate. Based on the vote,the winner candidate is selected. Implementation: This implementation starts from including numpy file. First,the candidates list is prepared and displayed. Number of users are received. User has to put the vote for any one of candidate. Based on the vote,those who got the maximum vote is declared as the winner. Python NumPy Code:   import numpy as np # Here is the Candidates list candidates = np.array(["jey", "baby", "sai"]) print("Candidates list:",candidates) # let us Collect the votes n = int(input("Enter number of voters: ")) votes = [] for i in range(n):     vote = input(f"Voter {i+1} vote: ")     votes.append(vote) votes = np.array(votes) # Count the number of votes for each candidate vote_counts = [] for candid...

Python Numpy Mini Projects:Stock Price Analyzer

                 This project analyses the stock prices. It has following functionalities. Code Implementation:               This program starts by creating stock by using NumPy array. The basic statistics include Average price, maximum, minimum prices and standard deviations. Next, Daily price changes are calculated using np.diff(prices). Daily returns price is calculated and the data is rounded to 2 digit. Stock Volatility is calculated and displayed. 7 day moving window is calculated along with average value. Best and worst days are displayed according to the returns value. It shows how a simple 30,000 initial value gives you profit. Code: import numpy as np # Sample stock closing prices prices = np.array([80, 100, 108, 120, 208, 110, 125, 311, 117]) print("Stock Prices:") print(prices) #Basic statistics print("The basic statistics of the da...

Python NumPy Mini Projects: Matrix Operations

                 Matrix is one of the important concepts in mathematics. It has rows and columns.It has many operations to perform as listed below ·        Addition ·        Row wise and column wise Sum ·        Subtraction ·        Element wise Multiplication ·        Multiplication ·        Transpose ·        Determinant ·        Inverse Matrix ·        Rank ·        Eigenvalues and EigenVector 👉Program implementation: import numpy as np rows = int(input("Enter rows: ")) cols = int(input("Enter columns: ")) print("Enter Matrix A:") A = np.array([[int(input()) for j in range(cols)] for i in range(rows)]) print("M...

Python NumPy Mini Projects: Movie Ratings Analyzer

              It is a beginner friendly mini project in NumPy mini Project. It reads the user reviews. Analyzes the reviews and make a good statistical reports. Let us implement this as follows… Implementation: This implementation starts from including numpy object. The movies names are assigned for an array. Ratings are recorder in another array. 4 parameters are calculated here. first, average of the reviews. It uses mean() function. Next, maximum and minimum calculation.This uses max() and min() functions. Finally, median rating is calculated by median(). These values are displayed. At last, the datas are sorted and displayed. Code: import numpy as np1 # Movie names movies = np1.array([     "Avengers:Doomsday",     "Spider-Man: Brand New Day",     "Jailer2",     "Titanic",     "Inception" ]) # Ratings out of 10 ratings = np1.array([...

Python Numpy MiniProjects : Implementation of Tic-Tac-Toe game

       Tic-Tac-Toe is a thinking game between two opponents. Each one has a symbol ‘o’ or ‘x’. The first person who built the three consecutive rows or columns or diagonals win the game. Opponent player will keep on move their symbols to make sure that opposite person should not make the three consecutive moves. Let us implement it using Numpy Arrays Implementation: import numpy as np1 # First a 3x3 game board is created board = np1.full((3, 3), "-") def display_board():     print("\nCurrent Board:")     print(board) def check_winner(player):     # Check for rows to find three consecutive moves     for row in board:         if np1.all(row == player):             return True     # Check columns for three consecutive columns     for col in board.T:   ...