0% found this document useful (0 votes)
0 views

Programming Report

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Programming Report

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

UNIT CODE:

MBIS4003

UNIT NAME:

Software Development

ASSESSMENT NUMBER:

ASSESSMENT 3 Part A

ASSESSMENT TYPE:

REPORT

SUBMITTED BY:

Himanshu 230983

Saema Naimbhai Jethra 234163

Bharti Yadav 231511

DATE:

August 25, 2024


TABLE OF CONTENTS

INTRODUCTION................................................................................................................................3
PROGRAM 1: CALCULATOR:........................................................................................................3
Output:............................................................................................................................................5
PROGRAM 2: STRING MANIPULATION......................................................................................5
Output:............................................................................................................................................7
PROGRAM 3: PRODUCT RATING:...............................................................................................8
Output:..........................................................................................................................................10
PROGRAM 4: WORD SCRAMBLE GAME:................................................................................12
Output:..........................................................................................................................................16
PROJECT MANAGEMENT............................................................................................................18
Planning:.......................................................................................................................................19
Development:...............................................................................................................................19
Testing:..........................................................................................................................................19
Integration:...................................................................................................................................19
CONCLUSION..................................................................................................................................19
INTRODUCTION
This report offers a thorough summary of a group effort including four separate
Python applications intended for both instructional and recreational use. Aimed at
improving learning and involvement for elementary school pupils, the programmes
provide a spectrum of features. The project consists of a Calculator for arithmetic
practice, a String Manipulation tool for text analysis and manipulation, a Product
Rating analysis system for statistical insights, and an interactive Word and Number
Arcade Game for fun and skill development. Three people worked on each
programme, working together on the last arcade game to provide a well-rounded and
coherent collection of teaching resources.

PROGRAM 1: CALCULATOR:
from collections import Counter

import string

import matplotlib.pyplot as plt

def analyze_string(s):

"""Analyzing string for letter frequency and checking alphabet coverage."""

s = s.lower()

s = ''.join(filter(str.isalpha, s)) # Removing non-letter characters

letter_counts = Counter(s)

alphabet = set(string.ascii_lowercase)

has_all_letters = alphabet <= set(s)

return letter_counts, has_all_letters

def generate_anagrams(s):

"""Generating anagrams of a given string."""

if len(s) <= 1:

return [s]

anagrams = []

for i, char in enumerate(s):

for anagram in generate_anagrams(s[:i] + s[i+1:]):


anagrams.append(char + anagram)

return anagrams

def plot_letter_frequencies(letter_counts):

"""Plotting bar chart of letter frequencies."""

letters, counts = zip(*sorted(letter_counts.items()))

plt.bar(letters, counts)

plt.xlabel('Letters')

plt.ylabel('Frequency')

plt.title('Letter Frequencies in String')

plt.show()

def main():

user_input = input("Enter a string: ")

letter_counts, has_all_letters = analyze_string(user_input)

print("Letter frequencies:")

for letter, count in letter_counts.items():

print(f"{letter}: {count}")

print("The string has all the letters of the alphabet." if has_all_letters else "The string does not
have all the letters of the alphabet.")

# Presenting descriptive statistics and graph

plot_letter_frequencies(letter_counts)

# Sorting letters and removing duplicates

unique_sorted_letters = ''.join(sorted(set(user_input.lower())))

print(f"Unique sorted letters: {unique_sorted_letters}")

# Sorting letters in different order


descending_sorted_letters = ''.join(sorted(set(user_input.lower()), reverse=True))

print(f"Letters sorted in descending order: {descending_sorted_letters}")

# Generating and displaying anagrams

anagrams = generate_anagrams(user_input)

print(f"Anagrams of the string: {', '.join(anagrams)}")

if __name__ == "__main__":

main()

Output:

PROGRAM 2: STRING MANIPULATION


from collections import Counter

import string

import matplotlib.pyplot as plt

def analyze_string(s):

"""Analyzing string for letter frequency and checking alphabet coverage."""

s = s.lower()

s = ''.join(filter(str.isalpha, s)) # Removing non-letter characters

letter_counts = Counter(s)

alphabet = set(string.ascii_lowercase)

has_all_letters = alphabet <= set(s)

return letter_counts, has_all_letters

def generate_anagrams(s):

"""Generating anagrams of a given string."""


if len(s) <= 1:

return [s]

anagrams = []

for i, char in enumerate(s):

for anagram in generate_anagrams(s[:i] + s[i+1:]):

anagrams.append(char + anagram)

return anagrams

def plot_letter_frequencies(letter_counts):

"""Plotting bar chart of letter frequencies."""

letters, counts = zip(*sorted(letter_counts.items()))

plt.bar(letters, counts)

plt.xlabel('Letters')

plt.ylabel('Frequency')

plt.title('Letter Frequencies in String')

plt.show()

def main():

user_input = input("Enter a string: ")

letter_counts, has_all_letters = analyze_string(user_input)

print("Letter frequencies:")

for letter, count in letter_counts.items():

print(f"{letter}: {count}")

print("The string has all the letters of the alphabet." if has_all_letters else "The string does not
have all the letters of the alphabet.")

# Presenting descriptive statistics and graph

plot_letter_frequencies(letter_counts)
# Sorting letters and removing duplicates

unique_sorted_letters = ''.join(sorted(set(user_input.lower())))

print(f"Unique sorted letters: {unique_sorted_letters}")

# Sorting letters in different order

descending_sorted_letters = ''.join(sorted(set(user_input.lower()), reverse=True))

print(f"Letters sorted in descending order: {descending_sorted_letters}")

# Generating and displaying anagrams

anagrams = generate_anagrams(user_input)

print(f"Anagrams of the string: {', '.join(anagrams)}")

if __name__ == "__main__":

main()

Output:
PROGRAM 3: PRODUCT RATING:
from collections import Counter

import numpy as np

import statistics

import matplotlib.pyplot as plt

def main():
ratings = []

print("Rate 20 products on a scale of 1 to 5 (1 being 'awful' and 5 being 'excellent').")

while len(ratings) < 20:

try:

rating = int(input(f"Product {len(ratings) + 1} rating: "))

if rating not in range(1, 6):

print("Please enter a rating between 1 and 5.")

continue

ratings.append(rating)

except ValueError:

print("Invalid input. Please enter a number between 1 and 5.")

# Calculating the frequency of each rating using Counter

rating_counts = Counter(ratings)

print("\nRating Frequencies:")

for rating, count in rating_counts.items():

print(f"Rating {rating}: {count}")

try:

# Calculating various descriptive statistics

min_rating = min(ratings)

max_rating = max(ratings)

rating_range = max_rating - min_rating

mean_rating = statistics.mean(ratings)

median_rating = statistics.median(ratings)

mode_rating = statistics.mode(ratings)

variance_rating = statistics.variance(ratings)

stdev_rating = statistics.stdev(ratings)

except statistics.StatisticsError as e:
print(f"Error calculating statistics: {e}")

return

print("\nStatistics:")

print(f"Minimum: {min_rating}")

print(f"Maximum: {max_rating}")

print(f"Range: {rating_range}")

print(f"Mean: {mean_rating}")

print(f"Median: {median_rating}")

print(f"Mode: {mode_rating}")

print(f"Variance: {variance_rating}")

print(f"Standard Deviation: {stdev_rating}")

# Displaying bar chart of rating frequencies

labels, values = zip(*rating_counts.items())

plt.bar(labels, values, tick_label=[f"Rating {r}" for r in labels])

plt.xlabel("Rating")

plt.ylabel("Frequency")

plt.title("Product Rating Frequencies")

plt.show()

if __name__ == "__main__":

main()

Output:
PROGRAM 4: WORD SCRAMBLE GAME:
import random

import time

from collections import defaultdict

import matplotlib.pyplot as plt

# Function to shuffle letters of a word

def scramble_word(word):

scrambled = ''.join(random.sample(word, len(word)))

return scrambled
# Word Scramble Game

def word_scramble_game():

words = ["education", "computer", "science", "programming", "python", "algorithm"]

word = random.choice(words)

scrambled_word = scramble_word(word)

print(f"Unscramble the word: {scrambled_word}")

attempts = 0

start_time = time.time()

while True:

guess = input("Your guess: ").strip().lower()

attempts += 1

if guess == word:

print("Correct! You unscrambled the word.")

break

else:

print("Wrong. Try again.")

end_time = time.time()

time_taken = end_time - start_time

print(f"You took {attempts} attempts and {time_taken:.2f} seconds to guess the word.")

return attempts, time_taken

# Number Guessing Game

def number_guessing_game():

number = random.randint(1, 100)

print("Guess the number between 1 and 100.")

attempts = 0

start_time = time.time()

while True:
try:

guess = int(input("Your guess: "))

attempts += 1

if guess < number:

print("Too low. Try again.")

elif guess > number:

print("Too high. Try again.")

else:

print("Correct! You've guessed the number.")

break

except ValueError:

print("Invalid input. Please enter a number.")

end_time = time.time()

time_taken = end_time - start_time

print(f"You took {attempts} attempts and {time_taken:.2f} seconds to guess the number.")

return attempts, time_taken

# Function to plot descriptive statistics

def plot_statistics(stats):

game_names = ["Word Scramble", "Number Guessing"]

attempts = [stats["word_scramble"]["attempts"], stats["number_guessing"]["attempts"]]

time_taken = [stats["word_scramble"]["time"], stats["number_guessing"]["time"]]

plt.figure(figsize=(10, 5))

plt.subplot(1, 2, 1)

plt.bar(game_names, attempts, color='blue')

plt.title('Attempts per Game')

plt.xlabel('Game')

plt.ylabel('Attempts')
plt.subplot(1, 2, 2)

plt.bar(game_names, time_taken, color='green')

plt.title('Time Taken per Game (seconds)')

plt.xlabel('Game')

plt.ylabel('Time (seconds)')

plt.tight_layout()

plt.show()

# Main function to run the arcade

def main():

stats = defaultdict(lambda: {"attempts": 0, "time": 0.0})

while True:

print("\nWelcome to the Word and Number Arcade!")

print("1. Play Word Scramble Game")

print("2. Play Number Guessing Game")

print("3. View Descriptive Statistics")

print("4. Exit")

choice = input("Choose an option (1-4): ")

if choice == '1':

attempts, time_taken = word_scramble_game()

stats["word_scramble"]["attempts"] += attempts

stats["word_scramble"]["time"] += time_taken

elif choice == '2':

attempts, time_taken = number_guessing_game()

stats["number_guessing"]["attempts"] += attempts

stats["number_guessing"]["time"] += time_taken
elif choice == '3':

plot_statistics(stats)

elif choice == '4':

print("Thank you for playing the Word and Number Arcade! Goodbye!")

break

else:

print("Invalid choice. Please enter a number between 1 and 4.")

if __name__ == "__main__":

main()

Output:
PROJECT MANAGEMENT
The project was managed efficiently through a collaborative approach, with each
team member focusing on specific tasks. The contributions were divided as follows:

Group Member Role and Contributions

Himanshu Developed Program 1: Calculator. Designed and implemented


(230983) the math problem generator, user interaction, and feedback
mechanism.

Saema Naimbhai Developed Program 2: String Manipulation. Focused on string


Jethra (234163) analysis, sorting, and generating anagrams.

Bharti Yadav Developed Program 3: Product Rating. Managed the


(231511) collection of ratings, performed statistical analysis, and
visualized the data.

All Members Contributed to Program 4: Word and Number Arcade Game.


Collaboratively designed and developed the games and the
arcade interface, and integrated statistical tracking.
Planning:

Tasks were distributed among members according to individual experience. To


handle deadlines and benchmarks, a chronology was developed. Planned were
frequent meetings to go over developments and handle any problems.

Development:

Every programme was developed under guidelines, coding each according to them.
Code changes were managed and team member cooperation was facilitated via
version control systems.

Testing:

Every application underwent extensive testing to guarantee usability and


functionality. Team member comments helped to verify the programmes satisfied
educational goals and enable required enhancements.

Integration:

For Programme 4, every participant worked together to create a unified arcade


experience out of separate contributions. This included combining many game
elements and guaranteeing flawless user interface.

CONCLUSION
In conclusion, the project successfully delivered four educational and entertaining
Python programs tailored for elementary students. Program 1 provides interactive
arithmetic practice, Program 2 offers insights into text analysis and manipulation,
Program 3 delivers detailed statistical analysis of product ratings, and Program 4
engages students through a fun and challenging arcade game. The collaborative
efforts of Himanshu, Saema, and Bharti ensured that each program was developed
with attention to detail and educational value. The project demonstrates effective
teamwork and the ability to leverage Python programming for creating impactful
educational tools.

You might also like