Posts

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