Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 52a78b9

Browse files
committed
Update
1 parent 1c5938e commit 52a78b9

19 files changed

+470
-35
lines changed

README-PYTHON-HOMEWORKS.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
2. ***Solve these problems*** ([**link**](/lessons/python/exercises/exercise-general-week-04.py)) <sub>[[ANSWERS](/lessons/python/exercises/exercise-general-week-04-answer.py)]</sub>
4848
</details>
4949

50-
<details open>
50+
<details>
5151
<summary><strong>Week 5</strong></summary>
5252

5353
1. Search for these terms:
@@ -64,16 +64,18 @@
6464
- Solve ball Grid problem ([**link**](/lessons/python/exercises/exercise-general-week-05-04.py))
6565
</details>
6666

67-
<details>
67+
<details open>
6868
<summary><strong>Week 6</strong></summary>
6969

7070
1. Search for these terms:
7171
- **Argument**, **Attribute**, **Parameter**, **Variable**, **Property**
7272
2. ***Solve these problems:***
7373
- Solve animal problem ([**link**](/lessons/python/exercises/exercise-general-week-05-06.py))
74+
- Solve this problem ([**link**](/lessons/python/exercises/exercise-general-week-06-01.py))
75+
- Unveil the first version of your project
7476
</details>
7577

76-
<details>
78+
<details open>
7779
<summary><strong>Week 7</strong></summary>
7880

7981
1. Search for these terms:
@@ -85,6 +87,7 @@
8587
- **Encapsulation**, **Polymorphism**
8688
- [**Magic Method**, **Class Method**, **Instance Method**, **Static Method**](/lessons/python/concepts/object-oriented/types-of-methods.py)
8789
2. ***Solve these problems*** ([**link**](/lessons/python/exercises/exercise-general-week-07.py))
90+
- Solve this problem ([**link**](/lessons/python/exercises/exercise-general-week-07-01.py))
8891
</details>
8992

9093
<details>

lessons/frontend/README.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1-
# WebSite, WebApp, WebService
1+
# Web
2+
- Site
3+
- App (PWA)
4+
- Service
5+
- ---
6+
- CMS
7+
- Web Frameworks
28

9+
## Web Roadmap
310
- Frontend
4-
- HTML, CSS <sub>(SCSS, SASS, ...)</sub>, JS <sub>(JQ, [ReactJS, VueJS, AngularJS], ThreeJS, BabylonJS, AnimeJS, PixiJS, ...)</sub>, TS
5-
- Bootstrap, Materialize, Framework7, ...
11+
- HTML
12+
- CSS
13+
- SCSS
14+
- SASS
15+
- CSS Frameworks
16+
- Bootstrap
17+
- Materialize CSS
18+
- Framework7
19+
- [JS](js/README.md)
20+
- [JQ](jq/README.md),
21+
- UI Web Application Framework ??
22+
- [ReactJS](react/README.md)
23+
- VueJS
24+
- AngularJS
25+
- ThreeJS, BabylonJS, AnimeJS, PixiJS, ...
26+
- TS
627
- Tools
728
- Babel, Webpack, NPM, ...
829
- Concepts
9-
- Basic Networking <sub>(Host, Domain, VPS, DNS, HTTP, HTTPS, FTP, SSH, ...)</sub>
30+
- [Basic Networking](../network/README.md) <sub>(Host, Domain, VPS, DNS, HTTP, HTTPS, FTP, SSH, ...)</sub>
1031
- PWA, SPA, [SSR, CSR, SSG, ISR]
1132
- Backend
1233
- Python
13-
- Django
14-
- Flask, Jinja, ...
34+
- [Django](../python/modules/django/README.md)
35+
- [Flask](../python/modules/flask/README.md)
1536
- NodeJS, NextJS, SocketIO, ...
37+
- Template Engine
38+
- Jinja
1639
- Database
17-
- SQL, NoSql, ORM <sub>(Prisma, Sequelize, SQLAlchemy, ...)</sub>, JSON, XML
40+
- [SQL](../sql/README.md), NoSql, ORM <sub>(Prisma, Sequelize, SQLAlchemy, ...)</sub>, JSON, XML
1841
- Web Services Architecture <sub>COAP, SOAP, RestAPI, GraphQL, ...</sub>
1942
- Deploy, Monitoring, ...
2043

lessons/frontend/js/README.md

+45-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,48 @@
3030
- [`instanceof, typeof`]()
3131
- [`class, extends, new, function, this, super, static`]()
3232
- [`void, debugger, in, delete`]()
33-
- Callback, Promise, ...
33+
- Objects
34+
- Strings
35+
- Actions
36+
- Access, Assign
37+
- Properties
38+
- `.length`
39+
- Classes
40+
- `String()`
41+
- Methods
42+
- `.toString(), .split(), .concat(), .trim(), .trimStart(), .trimEnd(), .padStart(), .padEnd(), .replace(), .slice(), .substring(), .substr(), .toUpperCase(), .toLowerCase(), .charAt(), .charCodeAt()`
43+
- `.search(), .indexOf(), .lastIndexOf(), .startsWith(), .endsWith()`
44+
- [Escape Chars](../../python/concepts/string/scape-chars.py)
45+
- Template (Format)
46+
- \`${}\`
47+
- Numbers
48+
- Collections
49+
- Array
50+
- Set
51+
- Map
52+
- If, Else, Switch
53+
- For, While, Break, Continue
54+
- Random
55+
- Date
56+
- Math
57+
- Class
58+
- Event, Callback, Promise, ...
59+
- Regular Expression
60+
- HttpRequest, Ajax, Fetch
61+
- ES6
62+
63+
## TP Week1
64+
- Output
65+
- `console.log()`
66+
- `window.alert()`
67+
- `window.print()`
68+
- `document.write()`
69+
- Id, Tag, Class, Name
70+
- `document.getElementById()`
71+
- Show/Hide Elements with JS
72+
- Change back/fore color of element
73+
- Change Text/HTML content of element
74+
75+
## TP Week2
76+
- External JS
77+
- ` <script src="script.js"></script> `

lessons/network/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
- Port
5151
- Subnet, Gateway
5252
- ARP
53+
- Configure by DHCP or Manually
54+
- Subnet Mask
55+
- Split address into host and network
5356

5457
---
5558
## Network Security
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from datetime import datetime,date,time
2+
3+
print(datetime.now())
4+
print(date(2020,12,10))
5+
print(time(hour=12,minute=31))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Shape:
2+
area = None
3+
4+
@classmethod
5+
def calc_area(cls, x, y=None, is_triangle=False):
6+
if y is None:
7+
cls.area = x * x
8+
else:
9+
cls.area = x * y
10+
11+
if is_triangle:
12+
cls.area /= 2
13+
14+
return cls.area
15+
16+
17+
print(Shape.calc_area(10))
18+
print(Shape.calc_area(10, 12))
19+
print(Shape.calc_area(10, 12, True))

lessons/python/examples/README.md

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
<style>
2-
img[src$="center"] {
3-
display:block;
4-
margin: 0 auto;
5-
}
6-
</style>
7-
8-
9-
10-
11-
121
# Python Micro Code Examples
13-
- ***Disclaimer**: The content of this repository is provided for learning purposes only and as a code example.*
2+
- ***Disclaimer**: The content of this repository is provided for teaching and learning purposes only and as a code example.*
3+
4+
## Simple Tank Game
5+
- [Tank Game](games/tank/tank.py)
6+
- [Movement and Rotation](games/dot_shooter/dot-shooter.py) of simple character
7+
- User A and D for rotation
8+
- Simple 2D Ball ([1](/lessons/python/examples/sample/game_engine/simple-2d-game-part1.py), [2](/lessons/python/examples/sample/game_engine/simple-2d-game-part2.py), [3](/lessons/python/examples/sample/game_engine/simple-2d-game-part3.py), [4](/lessons/python/examples/sample/game_engine/simple-2d-game-part4.py))
149

15-
## PyGame
16-
- [Dot Shooter](games/dot_shooter/dot-shooter.py)
10+
![](games/tank/snapshot.png)
1711

18-
## Tkinter, Flask
12+
## Online Communication Between Applications
1913
- Online Rock, Paper, Scissers Game using Flask Web Service: [Runner](games/rock_paper_scissers_online/runner.py), [All Files](games/rock_paper_scissers_online/)
2014

2115

2216
![](games/rock_paper_scissers_online/snapshot.png?style=center)
2317

24-
18+
## Paint
19+
- Simple paint ([1](/lessons/python/examples/apps/color/paint-01.py), [2](/lessons/python/examples/apps/color/paint-02.py)) using python and tkinter
20+
21+
![](/lessons/python/examples/apps/color/paint-02.png?style=center)
2522

2623

2724
----
@@ -44,10 +41,7 @@ img[src$="center"] {
4441
- Very simple GUI Random Dice using python and tkinter ([1](/lessons/python/examples/apps/random_dice/random-dice-01.py), [2](/lessons/python/examples/apps/random_dice/random-dice-02.py))
4542
- Color Detector ([1](/lessons/python/examples/apps/color/color-detector-01.py), [2](/lessons/python/examples/apps/color/color-detector-02.py))
4643
- Simple PhoneBook using python and tkinter ([CLI](/lessons/python/examples/apps/phone_book/phone-book-cli.py), [GUI](/lessons/python/examples/apps/phone_book/phone-book-gui.py))
47-
- Simple 2D Ball Game ([1](/lessons/python/examples/sample/game_engine/simple-2d-game-part1.py), [2](/lessons/python/examples/sample/game_engine/simple-2d-game-part2.py), [3](/lessons/python/examples/sample/game_engine/simple-2d-game-part3.py), [4](/lessons/python/examples/sample/game_engine/simple-2d-game-part4.py))
48-
- Simple paint ([1](/lessons/python/examples/apps/color/paint-01.py), [2](/lessons/python/examples/apps/color/paint-02.py)) using python and tkinter
49-
50-
![](/lessons/python/examples/apps/color/paint-02.png?style=center)
44+
5145
- Simple weekly CLI weight tracker ([1](/lessons/python/examples/apps/gym/weight-tracker-01.py), [2](/lessons/python/examples/apps/gym/weight-tracker-02.py))
5246

5347
![](/lessons/python/examples/apps/gym/weight-tracker-02.png?style=center)
Loading
10.6 KB
Loading
3.17 KB
Loading
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## python -m pip install pygame
2+
from math import radians, sin, cos
3+
import pygame
4+
import sys
5+
6+
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
class Config:
8+
W, H = 500, 500
9+
10+
11+
img = pygame.image.load(sys.path[0] + "/tank.png")
12+
13+
14+
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15+
class Player:
16+
x, y = Config.W // 2, Config.H // 2
17+
x_movement, y_movement = 8, 8
18+
radius = 10
19+
color = (255, 255, 255)
20+
angle = 0
21+
rotate_speed = 10
22+
23+
def move_up(self):
24+
self.y -= self.y_movement
25+
self.update_rotation(0)
26+
27+
def move_down(self):
28+
self.y += self.y_movement
29+
self.update_rotation(180)
30+
31+
def move_left(self):
32+
self.x -= self.x_movement
33+
self.update_rotation(90)
34+
35+
def move_right(self):
36+
self.x += self.x_movement
37+
self.update_rotation(270)
38+
39+
def update_rotation(self,deg):
40+
if self.angle>360:
41+
self.angle-=360
42+
43+
if self.angle<deg:
44+
self.angle+=self.rotate_speed
45+
elif self.angle>deg:
46+
self.angle-=self.rotate_speed
47+
48+
49+
50+
def draw(self, screen):
51+
tank = pygame.transform.rotate(img, self.angle)
52+
size = tank.get_rect().size
53+
screen.blit(tank, (player.x - size[0] // 2, player.y - size[1] // 2))
54+
55+
pygame.draw.circle(screen, self.color, (self.x, self.y), self.radius)
56+
57+
nx, ny = (
58+
self.x + self.radius * sin(radians(self.angle)),
59+
self.y + self.radius * cos(radians(self.angle)),
60+
)
61+
pygame.draw.circle(screen, self.color, (nx, ny), self.radius // 2)
62+
63+
64+
player = Player()
65+
66+
67+
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68+
screen = pygame.display.set_mode((Config.W, Config.H))
69+
pygame.display.set_caption("Tank Game")
70+
clock = pygame.time.Clock()
71+
72+
done = False
73+
while not done:
74+
for event in pygame.event.get():
75+
if event.type == pygame.QUIT:
76+
done = True
77+
78+
keys = pygame.key.get_pressed()
79+
80+
if keys[pygame.K_LEFT]:
81+
player.move_left()
82+
83+
if keys[pygame.K_RIGHT]:
84+
player.move_right()
85+
86+
if keys[pygame.K_UP]:
87+
player.move_up()
88+
89+
if keys[pygame.K_DOWN]:
90+
player.move_down()
91+
92+
clock.tick(60)
93+
screen.fill((30, 30, 30))
94+
player.draw(screen)
95+
pygame.display.update()

lessons/python/exercises/exercise-general-week-05-06.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
from enum import Enum
22

3-
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
##---------------------------------------------------------------------------##
4+
#
5+
#
6+
#
7+
8+
##---------------------------------------------------------------------------##
49
class RiskLevel(Enum):
510
WILD = 1
611
SAFE = 2
712
RISKY = 3
813

914

15+
##---------------------------------------------------------------------------##
1016
class Animal:
1117
name: str = None
1218
risk = RiskLevel.RISKY
@@ -27,6 +33,7 @@ def movement(self):
2733
pass
2834

2935

36+
##---------------------------------------------------------------------------##
3037
class Mamal(Animal):
3138
def movement(self):
3239
return "Walk"
@@ -41,10 +48,26 @@ class Fish(Animal):
4148
def movement(self):
4249
return "Swim"
4350

51+
##---------------------------------------------------------------------------##
52+
# تمرین ۱
53+
#
54+
#
55+
56+
##---------------------------------------------------------------------------##
57+
# تمرین ۲
58+
#
59+
#
60+
61+
##---------------------------------------------------------------------------##
62+
# تمرین ۳
63+
#
64+
#
65+
4466

4567
my_animals = []
4668

4769

70+
##---------------------------------------------------------------------------##
4871
my_animals.append(Mamal("Lion", RiskLevel.WILD))
4972
my_animals.append(Bird("BlueJay", RiskLevel.SAFE))
5073
my_animals.append(Bird("Hen"))
@@ -55,4 +78,4 @@ def movement(self):
5578
print(my_animals)
5679

5780
# EXERCISE:
58-
# Save to file
81+
# Save to file

0 commit comments

Comments
 (0)