PYTHON
Python is a high-level, general-purpose programming language. Its design
philosophy emphasizes code readability with the use of significant indentation via
the off-side rule. Python is dynamically typed and garbage-collected. It supports
multiple object-oriented and functional programming. It is often described as a
"batteries included" language due to its comprehensive standard library. Guido van
Rossum began working on Python in the late 1980s as a successor to the ABC
programming language and first released it in 1991 as Python 0.9.0. Python 2.0
was released in 2000. Python 3.0, released in 2008, was a major revision not
completely backward-compatible with earlier versions. Python 2.7.18, released in
2020, was the last release of Python 2. Python consistently ranks as one of the most
popular programming languages. The python IDLE (Integrated development &
learning Environment) executes instruction one line at a time. The python
programming language is one of the richest languages.
FEATURES OF PYTHON
EASY
Python is a very easy to learn and understand; using this python
tutorial, any beginner can understand the basis of python.
OBJECT ORIENTED
The python programming language supports classes and objects.
FREE AND OPEN-SOURCE
The language and it’s source code are available to the public for
free; there is no need to buy a costly license
PORTABLE
Since it is open source, we can run python on windows, mac,
linux, or any other platforms.
GUI(Graphical user interface) PROGRAMMING
We can use it to develop a GUI (Graphical user interface). One
way to do this is through ‘Tkinter’.
INTERPRETED
It is interpreted line by line. This makes it easy to test and
debug.
PYTHON LIBRARIES
1. NumPy (Numerical Python)
NumPy is used for numerical computing in Python. It provides support for arrays
(multidimensional arrays, matrices) and a variety of mathematical functions to
operate on these arrays.
2. Pandas (Python Data Analysis Library)
Pandas is primarily used for data manipulation and analysis. It introduces two key data
structures: Series (1D) and DataFrame (2D), which make it easier to manipulate and analyze
data.
3. Matplotlib (Plotting and Visualization)
Matplotlib is used for creating static, animated, and interactive visualizations.
It's great for plotting various types of charts and graphs.
CSV FILE
A CSV (Comma-Separated Values) file is a simple text file used to store tabular
data. Each line in the file represents a row, and columns are separated by commas.
It’s one of the most common formats for storing datasets and is widely used in data
analysis, including with libraries like Pandas in Python.
Here’s how you can work with CSV files in Python using Pandas and NumPy.
Reading CSV Files
To read a CSV file, you can use pandas.read_csv(), which automatically
loads the data into a DataFrame for easy manipulation.
Common Operations on CSV Data
1. Inspecting the Data
Once the CSV is loaded into a DataFrame, you can inspect it with a few Pandas
methods:
[Link]() - Show the first 5 rows.
[Link]() - Show the last 5 rows.
[Link]() - Show a concise summary of the DataFrame.
[Link]() - Show statistics of numerical columns.
Step 1: Create a CSV File ([Link])
Create a file named [Link] in the same folder as your Python script:
Word
Apple
Banana
Grapes
Orange
Melon
Step 2: Python Program
Import pandas as pd
Import numpy as np
Import [Link] as plt
# Step 1: Load words from CSV
Def load_words(filename=’[Link]’):
Df = pd.read_csv(filename)
Return df[‘word’].tolist()
# Step 2: Jumble a word using numpy
Def jumble_word(word):
Letters = list(word)
[Link](letters)
Return ‘’.join(letters)
# Step 3: Plot score progress
Def plot_scores(rounds, scores):
[Link](rounds, scores, marker=’o’, linestyle=’-‘, color=’blue’)
[Link](“Your Score Over Rounds”)
[Link](“Round”)
[Link](“Score”)
[Link](True)
[Link]()
# Step 4: Main game logic
Def play_game():
Words = load_words()
[Link](words) # Randomize word order
Rounds = []
Scores = []
Score = 0
Print(“🔤 Welcome to the Jumbled Word Game! 🔤”)
Print(“Type ‘exit’ to quit.\n”)
For I, word in enumerate(words, 1):
Jumbled = jumble_word(word)
Print(f”Round {i}: Unscramble → {jumbled}”)
Answer = input(“Your guess: “).strip().lower()
If answer == ‘exit’:
Break
If answer == word:
Print(“✅ Correct!\n”)
Score += 1
Else:
Print(f”❌ Incorrect. The word was: {word}\n”)
[Link](i)
[Link](score)
Print(f”\n🎮 Game Over! Final Score: {score}/{len(rounds)}”)
Plot_scores(rounds, scores)
# Run the game
If __name__ == “__main__”:
Play_game()
Output Example
🔤 Welcome to the Jumbled Word Game! 🔤
Round 1: Unscramble → nanaba
Your guess: banana
✅ Correct!
Round 2: Unscramble → lepap
Your guess: apple
✅ Correct!
🎮 Game Over! Final Score: 4/5