[go: up one dir, main page]

0% found this document useful (0 votes)
4 views20 pages

Unit V-Programming and Database

Uploaded by

mohammedict0926
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Unit V-Programming and Database

Uploaded by

mohammedict0926
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Unit-V

Teaching Programming and Database


by
informatics college

1
Outlines
Introduction
Basic teaching tools
Technologies for application development
Python and its basic
Database
CRUD operation using python script
Web development(HTML,CSS, Python and SQLite)

2
Activity 5.1

Tool Limitation Accessibility Suitable for Recommendation


👍 Strongly
Lack of Data ✅ Easy, Windows recommended for
Flowgram Grades 9–10
Handling Details only logic/algorithm
learning

Limited concurrent ✅ Available in MS 👍 Great for intro to


MS Access Grades 10–11
users<10 users Office databases

⚠️Use briefly, then


Not suited for large
Notepad ✅ Very basic Grades 9–10 switch to Notepad+
files
+ or VS Code

🌟 Best long-term
Not suitable for all ✅ Multiple free
Python IDE Grades 9–12 tool for teaching
languages options
programming

3
Activity 5.2 For web development
Tool / Technology Why It’s a Good Choice
Core technologies of the web. Easy to start with and visually
HTML, CSS, JavaScript
rewarding.

Beginner-friendly text editors with syntax highlighting and live


VS Code ,Notepad++, subline, spyder
preview extensions.

Live Server extension (VS Code) Let’s students instantly preview their websites in a browser.

Helps students create nice-looking websites without deep CSS


Bootstrap (optional)
knowledge.

GitHub Pages (optional) Let’s students publish their sites online for free.

Python with flask Popular technology for web

Database(SQL , MySQL, Mongo Db, SQLite) Provides students for managing data in local or online

4
For windows Programming
Tool / Language Why It’s a Good Choice

Easiest way to teach Windows GUI programming. It


Python with Tkinter
comes with Python and is simple for beginners.

Has a drag-and-drop GUI environment (e.g., Visual


Visual Basic (VB.NET) Studio). Good for younger learners and Windows-
focused apps.

More advanced, but widely used in the industry. Good


C# with Windows Forms (optional)
for students who have progressed beyond basics.

Thonny or IDLE Beginner IDEs for Python GUI projects.

5
Activity 5.3

Programming is the process of giving instructions to a computer to


perform specific tasks.
you write code (instructions) using a programming language like
Python, Java, or C++ to tell the computer what to do.
Python is a high-level, easy-to-read programming language used to
build all kinds of software — from websites and games to data
analysis and artificial intelligence.

6
Python
Area Example
Web Development Build websites with Flask or Django
Data Science Analyze data with Pandas, NumPy, Matplotlib
Machine Learning Build AI models with TensorFlow, Scikit-learn
Automation Automate boring tasks (files, emails, etc.)
Game Dev Create games using Pygame

7
Tools to Write Python

• IDLE (comes with Python) • Step 1: Install Python


• VS Code • Go to the official website:
• Jupyter Notebook (great for https://www.python.org
data science) • Click Download Python 3.x.x (the
• PyCharm latest version).
• Spyder • Run the installer.
• Step 2: Verify the Installation
• Open the Command Prompt
• Type: python –version

8
Step 3: Write Your First Program

A: Use IDLE (Python’s built-in editor)Open IDLE (installed with


Python).
Click: File → New File
Type this code: print("Hello, world!")
Save the file as hello.py
Press F5 to run the code.

9
Python Basics
• What is a Variable? For loop
• A variable is like a box where for i in range(10):
you can store a value. print('Hello’)
name = input('Enter your name: ') print Hello ten times
print('Hello, ', name) While loop
If/else statement count = 0
if age>= 50: while count < 3:
print(‘old’) print("Counting", count)
else : count += 1
Note : for more on python basics
print('young') refer to grade 11 & 12 textbooks
10
Database
• A database is a structured way to store, organize, and manage
information so a computer can retrieve and manipulate it easily.
common commands:
SELECT → Get data
INSERT → Add data
UPDATE → Change data
DELETE → Remove data

11
Activity 5.4

print("Welcome to the Quiz Game!")


else:
score = 0
count=0 print("Incorrect!")
trial=0
for tr in range(3): wq=int(input("how many campuses does wollo
cap=input("What is the capital of Ethiopia?").strip().lower() university have?"))
if cap== "addis ababa":
print("Correct!") count+=1
score += 1
break;
if wq== 3:
else: print("Correct!")
if(trial==0 or trial==1):
print("Incorrect try again!") score += 1
else:
print("incorrect");
else:
trial+=1
print("Incorrect!")
if(trial>2):
print(" you lost your chance!:you reached 3 trials") print("\nQuiz completed!")
count+=1
if cpu== "central processing unit": print(f"Your final score is: {score}/{count}")
print("Correct!")
score += 1
is: {score}/{len(questions)}")
12
Activity 5.5 part I

Python + Database Example (SQLite)


import sqlite3
conn = sqlite3.connect(“student.db") # you can use your database name
cursor = conn.cursor()
#create table
cursor.execute(''CREATE TABLE IF NOT EXISTS stud ( id int , name text, mark int)")
# insert data into your table
cursor.execute("INSERT INTO stud (id, name, grade) VALUES (?,?, ?)", (20,"XYZ", 90))
#save your changes
conn.commit()
#display information
cursor.execute("SELECT * FROM stud")
print(cursor.fetchall())
13
Cont…

#upade student mark


cursor.execute("UPDATE stud SET mark = 95 WHERE name = ?",
("XYZ",))
#delete data from stud table
cursor.execute("DELETE FROM stud WHERE name = ?", ("XYZ",))
conn.close()

14
Activity 5.5 part II (Python ,sqlite3, HTML and CSS )

Flask is important because it provides a lightweight and flexible way


to build web applications using Python
Install flask type: pip Install flask
Create one folder and then create 3 files
1. app.py
2. index.html
3. style.css
Note:
Use any editor to write python, html and CSS codes

15
App.py
from flask import Flask, render_template

import sqlite3 @app.route('/')


app = Flask(__name__)
def index():
def init_db():

conn = sqlite3.connect(student.db') conn = sqlite3.connect('student.db')


c = conn.cursor()
c = conn.cursor()
c.execute('''

CREATE TABLE IF NOT EXISTS stud ( c.execute('SELECT * FROM stud ')


id INTEGER PRIMARY KEY AUTOINCREMENT,
grades = c.fetchall()
name TEXT NOT NULL,

subject TEXT NOT NULL, conn.close()


grade INTEGER NOT NULL
return render_template('index.html',
)

''')
grades=grades)
c.execute("insert into stud(name,subject,grade) values(?,?,?)",("alemu","maths",100))

c.execute("insert into stud(name,subject,grade) values(?,?,?)",(“demere","en",100))

conn.commit()

conn.close() if __name__ == '__main__':


init_db()
app.run(debug=False)
16
Index.html

<!DOCTYPE html> {% for stud in grades %}


<html>
<head> <tr>
<title>Student Grades</title> <td>{{ stud{1] }}</td>
<link rel="stylesheet" href="{{ url_for('static',
filename='styles.css') }}"> <td>{{ stud[2] }}</td>
</head>
<td>{{ stud[3] }}</td>
<body>
<h1>Student grade information</h1> </tr>
<table> {% endfor %}
<tr>
<th>Name</th> </table>
<th>Subject</th> </body>
<th>Grade</th>
</tr> </html>
17
Style.css
body { table {
font-family: Arial, sans-serif;
width: 100%;
margin: 40px;
background-color: yellow; background-color: red;
} border: 10px;
}
h1 {
color: #333;
} th, td {
padding: 10px;
border: 1px solid #ccc;
}
18
To run the code

Type :Python app.py or press f5 //use run tab


Copy :http://127.0.0.1:5000
Past on your browser
Click enter button
View the information

19
Thank You!!

20

You might also like