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:   ...

Python Numpy Mini Projects: Sudoku Board Validator

Sudoku Board is mathematical board which has dimensions 9x9. You have to fill the numbers from 1 to 9 without duplication in columns or rows. Validation can be done by as follows. ·        Each row should have numbers 1-9 without duplicates. ·        Each column needs to filled with numbers 1-9 without repetition. ·        In the same way, each sub-grid should be filled with numbers 1-9 without overlapping. Program implementation: This code starts from importing numpy library. Two functions are created for validating the sudoku board.one is for shape. Another one is for elements. Input of the sudoku board is created with elements. First, shape is checked for number of rows and columns. Next one is for each row, each column and sub grid. Each one of the groups should be filled with 1to 9 without any repetition. Finally, the output is printed. Code: import numpy as np1 d...

Python Numpy Mini Projects: Cricket Score Analysis

              This program analyses a cricket player’s scores across many matches he/she played. It is a moderate mini project to implement. It needs some array to store the data, many functions are used. Here, is the implementation. Implementation: This implementation starts with include numpy and its object. The score details are included in the array and displayed. The following daata’s are calculated. Total runs,Average and highest scores are displayed. Century and half century values are noted. Scores above the average are displayed. Standard deviation values are calculated and displayed. Finally, best match and score are displayed. Code: import numpy as np1 #score board scores = np1.array(list(map(int, input("Enter the Cricket score of the player separated by space: \n ").split()))) print("Scores are displayed here:\n", scores) print("\nTotal Runs of the player:", np1.sum(scores)) print("Average Score of the pla...

Python Numpy Mini Projects: Simple Attendance System

               Attendance system is a common system which marks the student’s entry. when they are getting in to the school or college, it puts the attendance. Present means 1 and absent means 0. Let us implement this program. Implementation: This program creates a student array. Next, attendance entry matrix is created.   Attendance analysis is done as follows.. First, attendance percentage for each student is created according to the data. Next, below 75% attendance students are displayed separately. Code: import numpy as np1 # Student names students = np1.array(["Ajay", "Bob", "Charan", "Dia", "Marya", "Henry"]) # Attendance for 6 days (1 = Present, 0 = Absent) attendance = np1.array([     [1, 1, 0, 1, 1, 1],       [1, 0, 1, 1, 0, 0],       [1, 1, 1, 1, 1, 1],       [0, 1, 0, 1, 1, 0],       [1, 1, 1, 0, 1, 1],...

Python Miniprojects : Simulation of a dice roll

               Dice has 6 faces. Each one has a value. Here, ‘random.randint()’ function is used. Let us implement this. ·        Simple dice roll ·        Multiple dice roll ·        Using function ·        Object oriented approach Simple dice roll:               It uses randint() function to roll a dice with in the range 1 to 6. Code:   import random dice_result = random.randint(1, 6) print(f"The dice rolled: {dice_result}") Output: The dice rolled: 6 Multiple dice roll:               This method gets the input from the user about how many dice to roll. Based on the input, it rolls the dice and display the input. Code: import random num_dice = int(input("Enter...

Numpy Python Mini projects: Expense Tracker

               Expense tracker is one of the important applications in Numpy. It tracks the daily expenses, calculates the highest, lowest, average and total expenses. Let us implement the expense tracker in numpy. Implementation: First, built-in numpy library is included. It creates an array to read the input from the user. Print the array of elements. Next, total expenses are calculated by adding all elements in the array using sum() function. To find the ‘Average’ value by using mean() function in the numpy package. Other functions are included as follows. ‘max()’: it gives you the maximum value. ‘min()’: it finds the minimum value. It also checks the expense value is greater than 150 and calculates the sum and prints it. Code: import numpy as np1 # Let us create daily expenses s_expenses = np1.array(list(map(int, input("Enter the weekly expenses separated by space: ").split()))) print("Expenses of the week:", s_ex...

Numpy Python Mini Projects: Weather Data Analysis

                 If you want analyse the weather, then this is program. It uses the real world datasets with arrays. It combines indexing, masking to perform the process. Let us create a python program to implement weather data analysis. Implementation: It starts from including numpy object. Temperature data is collected from the user for a week. The average temperature for a week is calculated and printed. Next, minimum and maximum temperature is calculated using built-in functions. Hot days, cool days, rainy days are categorised by the temperature. Standard deviation is also calculated. Finally the weather report is displayed to the screen. Code: import numpy as np1 #Get the temperature inputs from the user temp = np1.array(list(map(int, input("Enter the weekly temperature separated by space: ").split()))) print("Temperature of the week",temp) #Average temperature,minimum,maximum temperature   calculation ...

Numpy Python Mini Projects: Student Marks Analyzer

#Mini Project 1: Student Mark Analyzer Create a Numpy Project to implements Student Marks Analysis. It creates a set of students as array. It includes the students name and marks. Find the average, minimum and maximum marks. Print the values. Check for passed students, failed students and distinction students. If the mark is greater than 40, then the student passed the exam. Otherwise, the student failed in the exam. For finding the distinction, check the mark is greater than 75. Finally, print the results. Let us print the grade based on the marks. If the mark is greater than or equal to 90, grade is ‘A+’. Else, if the mark is greater than or equal to 75,then the grade is ‘A’. Else if, the mark is greater than 60,the grade is ‘B’. else if the mark is less than 40, the student’s grade is ‘C’ and ‘F’. Finally, print the grade. Complete Program import numpy as np1 # Student data creation students = np1.array([     "Ajay",     "Bob", ...

Aggregation in Numpy

  What is Aggregation?               It combines the multiple values together and forms a single value. The value depends on the operation. Let us implement some aggregate functions in numpy using python. Implementation:               This program includes the numpy object. It creates an array of elements. It has following functions to provide aggregate functions. Sum : adds all elements together. Mean: finds the mean value. Median: finds the middle highest value. Min: it gives you the minimum value. Max: it gives you the maximum value. Std: it calculates the standard deviation. Argmin: it displays index of minimum value. Argmax: it gives you the index of maximum value. Code: import numpy as np1 s_arr = np1.array([11,12,13,14,15,16,17]) print("The original array is:",s_arr) a_sum = np1.sum(s_arr) a_mean=np1.mean(s_ar...

How to implement Statistics functions in Numpy using Python?

               This is a branch of mathematics. It collects the data, analyses it and present it accordingly. It has many methods which is used to find sum, average, minimum , maximum and so on. Let us implement the list of functions given below….. Sum: to find the total of all elements. Mean: it find the average value. Median :it gives you the middle value after sorting. Maximum :this function gives you maximum value of the array. Minimum: it provides the minimum value of the array. Standard deviation: it finds the standard deviation value. Variance: it is the square of the standard deviation. Product: it multiplies all elements. Cumulative sum: it gives the running total. Cumulative product: it finds the running product value. Program to find values for all functions: import numpy as np1 s_arr = np1.array([11,12,13,14,15,16]) s_sum= np1.sum(s_arr) s_prod = np1.prod(s_arr) s_mean = np1.mean(s_arr) s_medi = np1....