├── .gitattributes ├── .idea ├── .gitignore ├── PythonLessons.iml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── .vscode └── launch.json ├── Archive ├── Arithmatic.py ├── E_Y_project │ └── main.py ├── LeeTcode.py ├── PyGameLib.py ├── TkinterBasic.py ├── WebScript.py ├── dataType.py ├── functions.py ├── myturtle.py └── simon.py ├── Python43025 ├── Code_Examples │ ├── Tigbor1109.py │ ├── Tiktakto.py │ ├── __pycache__ │ │ └── tkinter.cpython-310.pyc │ ├── code_to_print.py │ ├── customTk.py │ ├── functions.py │ ├── hw1.py │ ├── lesson1.py │ ├── lesson3Help.py │ ├── mytkinter.py │ ├── tibor1409.py │ ├── tigbor.py │ ├── tigbor6922.py │ ├── tirgol2009.py │ ├── whileloops.py │ └── whileloops_short.py ├── Lessons │ ├── LessonFive.py │ ├── LessonOne.py │ ├── lesson.txt │ ├── lessonFour.py │ ├── lessonThree.py │ ├── lessonTwo.py │ ├── lesson_1.py │ ├── lesson_10.py │ ├── lesson_11.py │ ├── lesson_12.py │ ├── lesson_13.py │ ├── lesson_14.py │ ├── lesson_2.py │ ├── lesson_eight.py │ ├── lesson_nine.py │ ├── lesson_seven.py │ ├── lesson_six.py │ ├── methods.py │ └── p.py ├── class_notes │ └── loop.py └── static │ ├── ASCII-Table-wide.svg.png │ └── asciifull.gif ├── PythonLibs ├── algo.py └── mytkinter.py ├── Readme.md └── TeacherComment.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/PythonLessons.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 49 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal", 13 | "justMyCode": true 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /Archive/Arithmatic.py: -------------------------------------------------------------------------------- 1 | # arithmatic oprators {*,**,+,-,/,//} 2 | 3 | a = 5 4 | b = 2 5 | 6 | c = a + b 7 | d = a - b 8 | 9 | e = c/d 10 | 11 | print(type(e)) 12 | 13 | # numbers - Int and Float 14 | 15 | 16 | name = input() 17 | lastname = input() 18 | print("hello {1} {0}".format(name, lastname)) 19 | 20 | 21 | # other data types 22 | 23 | -------------------------------------------------------------------------------- /Archive/E_Y_project/main.py: -------------------------------------------------------------------------------- 1 | ## Text to Speech 2 | from mpyg321.MPyg123Player import MPyg123Player # or MPyg321Player if you installed mpg321 3 | 4 | # source: https://www.geeksforgeeks.org/convert-text-speech-python/ 5 | 6 | # Import the required module for text 7 | # to speech conversion 8 | from gtts import gTTS 9 | 10 | # This module is imported so that we can 11 | # play the converted audio 12 | import os 13 | 14 | # The text that you want to convert to audio 15 | mytext = "this is Emily's and Yaniv's first Projects as advencted python programmers!" 16 | 17 | # Language in which you want to convert 18 | language = 'en' 19 | 20 | # Passing the text and language to the engine, 21 | # here we have marked slow=False. Which tells 22 | # the module that the converted audio should 23 | # have a high speed 24 | myobj = gTTS(text=mytext, lang=language, slow=False) 25 | 26 | # Saving the converted audio in a mp3 file named 27 | # welcome 28 | myobj.save("welcome.mp3") 29 | 30 | # Playing the converted file 31 | #os.system("mpg321 welcome.mp3") 32 | 33 | 34 | 35 | # source : https://pypi.org/project/mpyg321/ 36 | player = MPyg123Player() 37 | player.play_song("C:\Users\Mai\Desktop\Python\welcome.mp3") -------------------------------------------------------------------------------- /Archive/LeeTcode.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def twoSum(self, nums, target, lst=[]): 3 | """ 4 | :type nums: List[int] 5 | :type target: int 6 | :rtype: List[int] 7 | """ 8 | 9 | 10 | print(Solution().twoSum([3, 2, 4], 6)) 11 | -------------------------------------------------------------------------------- /Archive/PyGameLib.py: -------------------------------------------------------------------------------- 1 | # from pygame import mixer 2 | 3 | # #start mixer 4 | 5 | # mixer.init() 6 | 7 | # # load the sound acoording the relative path 8 | # mysound = mixer.Sound("Sound1.mp3") 9 | 10 | # # play the sound 11 | 12 | # mixer.Sound.play(mysound) 13 | 14 | from random import random 15 | import pygame 16 | 17 | pygame.init() 18 | 19 | dis = pygame.display.set_mode((400, 600)) 20 | pygame.display.set_caption("Game!") 21 | 22 | blue = (0, 0, 255) 23 | red = (255, 0, 0) 24 | 25 | 26 | 27 | 28 | gameOver = False 29 | 30 | 31 | 32 | while not gameOver: 33 | for event in pygame.event.get(): 34 | counter = random() 35 | if event.type == pygame.QUIT: 36 | gameOver = True 37 | pygame.draw.rect(dis,blue,[290,150,10+counter,10+counter]) 38 | pygame.display.update() 39 | 40 | pygame.quit() 41 | quit() 42 | -------------------------------------------------------------------------------- /Archive/TkinterBasic.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import ttk 3 | 4 | 5 | def main(): 6 | root = Tk() 7 | frm = ttk.Frame(root,padding = 10) 8 | frm.grid() 9 | ttk.Label(frm, text="May Lindenberg").grid(column=0, row=0) 10 | ttk.Button(frm,text="Quit", command=root.destroy).grid(column=1, row=0) 11 | root.mainloop() 12 | 13 | main() 14 | 15 | -------------------------------------------------------------------------------- /Archive/WebScript.py: -------------------------------------------------------------------------------- 1 | import webbrowser 2 | f=open("index.html","w") 3 | m=""" 4 | 5 | 6 | 36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 |

name:

45 |

hearName

46 |
47 |

city:

48 |

hearCity

49 |
50 |

age:

51 |

hearAge

52 | 53 | 54 |
55 |
56 |
57 | 58 | 59 |
60 | """ 61 | 62 | 63 | 64 | name=input("my name ")#המשתמש הולך לכתוב את השם שלו 65 | city=input("my city ")#המשתמש הולך לכתוב שאת העיר שלו 66 | age=input("my age ")#המשתמש הולך לכתוב שאת הגיל שלו 67 | 68 | m=m.replace("hearName",name) 69 | m=m.replace("hearCity",city) 70 | m=m.replace("hearAge",age) 71 | 72 | f.write(m) 73 | f.close() 74 | 75 | webbrowser.open_new_tab('index.html') 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Archive/dataType.py: -------------------------------------------------------------------------------- 1 | ##--data type--## 2 | 3 | 4 | """ 5 | lesson Tools: 6 | 7 | type(a) = the type fuction return the data type of a, 8 | 9 | print(a) = print(a) to the console 10 | 11 | """ 12 | 13 | 14 | number = 12345678 15 | 16 | 17 | 18 | 19 | 20 | # ----- exple ----# 21 | 22 | def main(): 23 | # ----primitives----# 24 | a = 15 # integer or int for sort a whole number 25 | b = "a" # str/char -!!! in python we str or string type to reprianct a single charicter or a string of charicters 26 | c = 15.4 # float a decimal point number 27 | d = True # boolean or bool for short is a binaty type being ethier one for true or zero for false 28 | print("----------------") 29 | print(a, b, c, d) 30 | print("----------------") 31 | print(type(a), type(b), type(c), type(d)) 32 | for i in range(5): 33 | print("----------------") 34 | 35 | 36 | main() 37 | -------------------------------------------------------------------------------- /Archive/functions.py: -------------------------------------------------------------------------------- 1 | def Jelly(name): 2 | print("hello ", name) 3 | print(name, "GoodBy") 4 | 5 | 6 | 7 | 8 | mylist = ["may","itay","ziv", "Emily", "Oshri"] 9 | for i in mylist: 10 | Jelly(i) 11 | -------------------------------------------------------------------------------- /Archive/myturtle.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | color('red', 'yellow') 3 | begin_fill() 4 | while True: 5 | forward(200) 6 | left(170) 7 | if abs(pos()) < 1: 8 | break 9 | end_fill() 10 | done() -------------------------------------------------------------------------------- /Archive/simon.py: -------------------------------------------------------------------------------- 1 | from random import choice 2 | from time import sleep 3 | from turtle import * 4 | import winsound 5 | from freegames import floor, square, vector 6 | 7 | pattern = [] 8 | guesses = [] 9 | tiles = { 10 | vector(0, 0): ('red', 'dark red'), 11 | vector(0, -200): ('blue', 'dark blue'), 12 | vector(-200, 0): ('green', 'dark green'), 13 | vector(-200, -200): ('yellow', 'khaki'), 14 | } 15 | 16 | 17 | def grid(): 18 | """Draw grid of tiles.""" 19 | square(0, 0, 200, 'dark red') 20 | square(0, -200, 200, 'dark blue') 21 | square(-200, 0, 200, 'dark green') 22 | square(-200, -200, 200, 'khaki') 23 | update() 24 | 25 | 26 | def flash(tile): 27 | """Flash tile in grid.""" 28 | glow, dark = tiles[tile] 29 | square(tile.x, tile.y, 200, glow) 30 | update() 31 | sleep(0.5) 32 | square(tile.x, tile.y, 200, dark) 33 | update() 34 | sleep(0.5) 35 | 36 | 37 | def grow(): # this functiong does 1. 2. 3. 38 | """Grow pattern and flash tiles.""" 39 | tile = choice(list(tiles)) 40 | pattern.append(tile) 41 | 42 | for tile in pattern: 43 | flash(tile) 44 | 45 | print('Pattern length:', len(pattern)) 46 | guesses.clear() 47 | 48 | 49 | def tap(x, y): 50 | """Respond to screen tap.""" 51 | onscreenclick(None) 52 | x = floor(x, 200) 53 | y = floor(y, 200) 54 | tile = vector(x, y) 55 | index = len(guesses) 56 | 57 | if tile != pattern[index]: 58 | exit() 59 | 60 | guesses.append(tile) 61 | flash(tile) 62 | 63 | if len(guesses) == len(pattern): 64 | grow() 65 | 66 | onscreenclick(tap) 67 | 68 | 69 | def start(x, y): 70 | """Start game.""" 71 | grow() 72 | onscreenclick(tap) 73 | 74 | def playmusic(): 75 | winsound.PlaySound('w.mp3',winsound.SND_ASYNC) 76 | 77 | 78 | def main(): 79 | 80 | setup(420, 420, 370, 0) # setup the screen 81 | hideturtle() 82 | tracer(False) 83 | grid() # draw the grid 84 | onscreenclick(start) # start the game 85 | done() 86 | 87 | main() 88 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/Tigbor1109.py: -------------------------------------------------------------------------------- 1 | # name = "May Lindenberg" 2 | # id_number = 313131313 3 | # print(name[0]) # -> M 4 | # seperator = ",+_()&^12341%$#@!~" 5 | # print(len(seperator)) 6 | 7 | # for i in seperator: 8 | # print("the of i: ", i) 9 | # # print(name, id_number, sep=i) 10 | 11 | 12 | # for i in range(len(name)): 13 | # if i % 2 == 0: 14 | # print(name[i], end=" ") 15 | 16 | 17 | # print("Amit", sep=" ", end="\n") 18 | # print("Amit") 19 | 20 | # name = "Amit" 21 | # print(name[0]) 22 | # print(name[-4]) 23 | # for i in range(50,0,-1): 24 | # print(i) 25 | 26 | 27 | #function: 28 | param = "Amit15" 29 | print(param) 30 | 31 | 32 | #method: 33 | print(param.upper()) 34 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/Tiktakto.py: -------------------------------------------------------------------------------- 1 | # print(a) == print(a, end='\n') 2 | 3 | 4 | 5 | matrix = [[0,0,0],[0,0,0],[0,0,0]] 6 | 7 | # for row in range(len(matrix)): 8 | # for col in range(len(matrix[row])): 9 | # matrix[row][col] 10 | 11 | ## game of tiktaktoe 12 | flag = True 13 | while flag: 14 | print("welcome to tiktaktoe!") 15 | #player_name = input("enter your name: ") 16 | 17 | user_move = input("enter your move 0,0: ") 18 | 19 | user_move = user_move.split(",") 20 | row = user_move[0] 21 | col = user_move[1] 22 | 23 | row = int(row) 24 | col = int(col) 25 | 26 | if matrix[row][col] == 0: 27 | matrix[row][col] = 'X' 28 | 29 | for i in range(len(matrix)): 30 | for j in range(len(matrix[i])): 31 | print(matrix[i][j], end=" ") 32 | print() 33 | 34 | 35 | 36 | 37 | 38 | 39 | # print the matrix 40 | 41 | # for row in range(3): 42 | 43 | # for col in range(3): 44 | # print(0, end=' ') 45 | 46 | # print() -------------------------------------------------------------------------------- /Python43025/Code_Examples/__pycache__/tkinter.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CheesiePy/PythonLessons/e0f78d2cb10a8f6a78ee8a2fbf25cf612a036bfa/Python43025/Code_Examples/__pycache__/tkinter.cpython-310.pyc -------------------------------------------------------------------------------- /Python43025/Code_Examples/code_to_print.py: -------------------------------------------------------------------------------- 1 | import webbrowser 2 | f=open("index.html","w") 3 | m=""" 4 | 5 | 6 | 36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 |

name:

45 |

hearName

46 |
47 |

city:

48 |

hearCity

49 |
50 |

age:

51 |

hearAge

52 | 53 | 54 |
55 |
56 |
57 | 58 | 59 |
60 | """ 61 | 62 | 63 | 64 | name=input("my name ")#המשתמש הולך לכתוב את השם שלו 65 | city=input("my city ")#המשתמש הולך לכתוב שאת העיר שלו 66 | age=input("my age ")#המשתמש הולך לכתוב שאת הגיל שלו 67 | 68 | m=m.replace("hearName",name) 69 | m=m.replace("hearCity",city) 70 | m=m.replace("hearAge",age) 71 | 72 | f.write(m) 73 | f.close() 74 | 75 | webbrowser.open_new_tab('index.html') -------------------------------------------------------------------------------- /Python43025/Code_Examples/customTk.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | 3 | customtkinter.set_appearance_mode('dark') 4 | customtkinter.set_default_color_theme('green') 5 | 6 | root = customtkinter.CTk() 7 | root.title('Custom Tkinter') 8 | root.geometry('400x400') 9 | 10 | def login(): 11 | print('Login') 12 | 13 | frame = customtkinter.CTkFrame(master=root) 14 | frame.pack(pady=20, padx=60, fill='both', expand=True) 15 | 16 | label = customtkinter.CTkLabel(master=frame, text='Logic Systems') 17 | label.pack(pady=12, padx=10) 18 | 19 | entry1 = customtkinter.CTkEntry(master=frame, placeholder_text='Username') 20 | entry1.pack(pady=12, padx=10) 21 | 22 | entry2 = customtkinter.CTkEntry(master=frame, placeholder_text='Password', show='*') 23 | entry2.pack(pady=12, padx=10) 24 | 25 | button = customtkinter.CTkButton(master=frame, text='Login', command=login) 26 | button.pack(pady=12, padx=10) 27 | 28 | checkbox = customtkinter.CTkCheckBox(master=frame, text='Remember me') 29 | checkbox.pack(pady=12, padx=10) 30 | 31 | root.mainloop() 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/functions.py: -------------------------------------------------------------------------------- 1 | # def add_one_add_print(x): # print and return (x + 1) 2 | # print(x + 1) 3 | # return (x + 1) 4 | 5 | 6 | # def mult(x,y): 7 | # return x*y 8 | 9 | 10 | 11 | matrix = [[0,1,2],[3,4,5],[6,7,8],] 12 | print(matrix[29][0]) 13 | 14 | 15 | 16 | def n_print(str, num): 17 | for i in range(num): 18 | print(str,str) 19 | 20 | n_print("may", 6) 21 | n_print("hello", 7) 22 | n_print("world", 8) 23 | n_print("python", 9) 24 | 25 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/hw1.py: -------------------------------------------------------------------------------- 1 | print("give me a 100!") 2 | 3 | 4 | def sum(a, b): 5 | print(a, b) 6 | return a + b 7 | 8 | x = 5 9 | y = 6 10 | 11 | sum(x,y) -------------------------------------------------------------------------------- /Python43025/Code_Examples/lesson1.py: -------------------------------------------------------------------------------- 1 | var1 = "hello world" 2 | var2 = var1 +" Good Bye world" 3 | var3 = 5 4 | 5 | jelly, bean = "Hello", "World" 6 | 7 | #"Hello World" 8 | #"Hello,World" 9 | #"Hello|World" 10 | #"Hello\World" 11 | 12 | 13 | 14 | print(jelly,bean, sep="+") 15 | print(jelly,bean, sep="|") 16 | print(jelly,bean, sep="\\") 17 | print(jelly,bean, sep=" ") 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | print('5' + '5') # -> 55 27 | print(5 + 5) # -> 10 28 | 29 | # number = 5 30 | # print(number*2) # -> 10 31 | # print(str(number)*2) # casting from int to str 32 | 33 | 34 | 35 | # mystring = "5" 36 | # print(mystring*2) # casting from str to int ### must be a digit 37 | 38 | # number = int(input("please: ")) 39 | # print(number*5) 40 | 41 | print(type(1)) 42 | print(type(1.0)) 43 | print(0.0 == 0) 44 | 45 | 46 | #ctrl + / to mute a line 47 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/lesson3Help.py: -------------------------------------------------------------------------------- 1 | #print("hello world") 2 | 3 | mystring = "hello world" 4 | # print(mystring) 5 | 6 | my_list = mystring.split() 7 | # # print(type(my_list)) 8 | 9 | # # print(my_list[0][-1]) 10 | 11 | # for char in mystring: 12 | # print(char) 13 | # print("-----------") 14 | # for str in my_list: 15 | # print(str) 16 | # print("------------") 17 | # for i in range(len(my_list)): 18 | # print() 19 | # for j in range(len(mystring)): 20 | # print(my_list[i], mystring[j], sep= ",", end="") 21 | 22 | start = 0 23 | stop = len(mystring) # lenth of mystring = 11 24 | jump = -2 25 | 26 | 27 | 28 | single_char = mystring[0] ## char in location 0 29 | group_chars = mystring[::jump] ## chars in location 0 to 6 in steps of 1 30 | print(group_chars) 31 | 32 | print("-----------") 33 | rev_str = mystring[::-1] 34 | rev_list =my_list[::-1] 35 | print(rev_str, rev_list, sep="+") 36 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/mytkinter.py: -------------------------------------------------------------------------------- 1 | # import the tkinter module 2 | from tkinter import * 3 | from tkinter import ttk 4 | 5 | # create the root window 6 | root = Tk() 7 | 8 | 9 | # create a frame in the window to hold other widgets 10 | frm = ttk.Frame(root, padding=100) 11 | frm.grid() # use the grid geometry manager 12 | 13 | ttk.Label(frm, text="Hey my friend").grid(column=0, row=0) 14 | ttk.Button(frm, text="Quit", command=root.destroy).grid(column=0, row=1) 15 | 16 | 17 | # start the GUI 18 | root.mainloop() -------------------------------------------------------------------------------- /Python43025/Code_Examples/tibor1409.py: -------------------------------------------------------------------------------- 1 | def add(a,b): 2 | for i in range(15): 3 | print(a, b) 4 | 5 | add("5","hello") 6 | add("hello", "world") 7 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/tigbor.py: -------------------------------------------------------------------------------- 1 | """ 2 | 1. variubles 3 | 2. data types 4 | 3. input 5 | 4. loops 6 | 5. functions 7 | """ 8 | 9 | # 1. variables 10 | var_name = "Tigbor" 11 | var_age = 25 12 | 13 | # 2. data types 14 | # string, int, float, boolean *-> to be learn (list, tuple, dictionary) 15 | 16 | # 3. input 17 | name = input("What is your name? ") 18 | print(name) 19 | 20 | 21 | # 4. loops 22 | name = "Adam is the man!" 23 | 24 | for i in range(10): 25 | print(type(i)) 26 | 27 | for i in name: # by value 28 | print(i) 29 | 30 | for i in range(len(name)): # by index 31 | if i%2 == 0: 32 | print(i, end=" ") 33 | print(name[i]) 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/tigbor6922.py: -------------------------------------------------------------------------------- 1 | def crazy_func(number): 2 | 3 | mylist = [] 4 | for i in range(number): 5 | if i % 2 == 0 and i % 3 == 0: 6 | mylist.append(i) 7 | return mylist 8 | 9 | x = crazy_func(100) 10 | x.append("mango") 11 | print(x) 12 | 13 | 14 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/tirgol2009.py: -------------------------------------------------------------------------------- 1 | matrix = [[0,0,0],[1,2,1],[2,2,2]] 2 | 3 | mega_list = [[0,15,2],[],[2]] 4 | 5 | my_list = [] 6 | 7 | # for i in range(0): 8 | # print(i) 9 | 10 | # for i in my_list: 11 | # print(i) 12 | 13 | 14 | for index in mega_list: 15 | print(index) 16 | for jelly in index: 17 | print(jelly) 18 | 19 | 20 | for counter in range(15): 21 | print(counter) 22 | 23 | 24 | 25 | # print(mega_list) 26 | 27 | # for i in mega_list: 28 | # print(i) 29 | -------------------------------------------------------------------------------- /Python43025/Code_Examples/whileloops.py: -------------------------------------------------------------------------------- 1 | ## לולאה שאנחנו לא יודעים מראש כמה פעמים היא תחזור על עצמה 2 | 3 | 4 | 5 | 6 | #print(type(flag)) 7 | 8 | # for i in range(100): 9 | # if i % 3 == 0: 10 | # print(i) 11 | 12 | 13 | from re import I 14 | 15 | 16 | flag = True 17 | counter = 0 18 | 19 | 20 | # while flag: 21 | # counter += 1 22 | # print("Hello", end='') 23 | # if counter == 10 < 7: 24 | # flag = False 25 | # print("Goodbye") 26 | # break 27 | # if counter < 7: 28 | # print("Bye", end='') 29 | 30 | # else: 31 | # print("!") 32 | 33 | 34 | # print(counter) 35 | 36 | ## a = 97 z = 122 37 | while flag: 38 | user_input = input("Enter a letter: ") 39 | if user_input == "Quit": 40 | flag = False 41 | break 42 | if len(user_input) > 1: 43 | print("Please enter only one letter") 44 | continue 45 | print("You entered: ", user_input) 46 | sypher = 3 47 | dest = ((ord(user_input) + sypher) % 26) + 97 48 | print(chr(dest)) -------------------------------------------------------------------------------- /Python43025/Code_Examples/whileloops_short.py: -------------------------------------------------------------------------------- 1 | from turtle import * # import the turtle module 2 | import math # import the math module 3 | 4 | # set up the screen 5 | ## set the size of the screen 6 | Turtle() 7 | getscreen() 8 | bgcolor('black') # set the background color to black 9 | color('red') # set the pen color to red 10 | speed(0) # set the speed to 0 11 | #fillcolor('red') # set the fill color to red 12 | pensize(2) # set the pen width to 3 13 | counter = 0 # set the counter to 0 14 | while True: # create a while loop 15 | #shape(name='triangle') # draw a triangle' 16 | goto(counter/math.pi * math.cos(counter/(math.e/math.pi)), 17 | counter/math.e * math.sin(counter/(math.e/math.pi))) # move to the next point 18 | counter += 1 # add 1 to the counter 19 | 20 | if counter % 3 == 0: 21 | color('red') # change the pen color to green 22 | # elif counter % 5 == 0: 23 | # color('purple') # change the pen color to green 24 | elif counter % 7 == 0: 25 | color('blue') 26 | #elif counter % 11 == 0: 27 | # color('teal') 28 | else: 29 | color('lightblue') 30 | -------------------------------------------------------------------------------- /Python43025/Lessons/LessonFive.py: -------------------------------------------------------------------------------- 1 | ## Function in Python! 2 | 3 | ## Functions are a way to reuse code. 4 | 5 | if 5 > 2: ## condition -> True or False 6 | print("V") 7 | print("mango juice") 8 | 9 | 10 | for i in range(6): ## loop 11 | print(i) 12 | print("mango juice") 13 | 14 | 15 | while 1 > 2: ## loop - while loop - while condition is true 16 | print("V") 17 | 18 | def greeting(): ## define a function -> retrun string value 19 | name = input("Enter your name: ") 20 | if validate_greeting(name): 21 | return name 22 | else: 23 | return "John Doe" 24 | 25 | def validate_greeting(name): ## define a function with parameters 26 | if not name.isalpha() or not len(name) < 3: 27 | return False 28 | else: 29 | return True 30 | 31 | def print_greeting(): 32 | print("Hello", greeting()) 33 | 34 | 35 | def print_greeting_2(name="John Doe"): ## define a function with parameters 36 | print("Hello", name) 37 | 38 | 39 | def main(): ## main function 40 | # home work define crazy_func function 41 | 42 | x = "maylindenberg" 43 | print(crazy_func(x)) # -> crazy_func return -> "MaYliNdEnGeR" this 44 | main() ## main function call 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Python43025/Lessons/LessonOne.py: -------------------------------------------------------------------------------- 1 | #------data type-------# 2 | 3 | 4 | 5 | """ 6 | lesson Tools: 7 | 8 | type(a) = the type fuction return the data type of a, 9 | print(a) = print(a) to the console 10 | 11 | """ 12 | 13 | # ----primitives----# 14 | a = 15 # integer or int for sort a whole number 15 | b = "a" # str/char -!!! in python we str or string type to reprianct a single charicter or a string of charicters 16 | c = 15.4 # float a decimal point number 17 | d = True # boolean or bool for short is a binary type being ethier one for true or zero for false 18 | print("----------------") 19 | print(a, b, c, d) 20 | print("----------------") 21 | print(type(a), type(b), type(c), type(d)) 22 | for i in range(5): 23 | print("----------------") 24 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson.txt: -------------------------------------------------------------------------------- 1 | may_age = "blablbal" 2 | may_age = 29 3 | print(may_age) -> -------------------------------------------------------------------------------- /Python43025/Lessons/lessonFour.py: -------------------------------------------------------------------------------- 1 | # range function parameters: 2 | start = 0 # start is the first number in the range 3 | stop = 51 # stop is the last number in the range 4 | jump = 1 # jump is the number to add to the start number each time the loop iterates 5 | 6 | ## for loops and range function 7 | for i in range(start, stop, jump): 8 | print(i, end='\t') 9 | 10 | # notes: 11 | 12 | # \ back slash 13 | # / forward slash 14 | 15 | # print parameters: 16 | # sep = " " # separator 17 | # end = "\n" # end of line 18 | # \n new line 19 | # \t tab 20 | 21 | 22 | # WRONG: split(mystring) 23 | # x = mystring.split() 24 | 25 | 26 | mystr = "Hello my friends at progeeks python class" 27 | 28 | mylongstr = """Hello my friends at progeeks python class 29 | Hello my friends at progeeks python class 30 | Hello my friends at progeeks python class 31 | Hello my friends at progeeks python class 32 | Hello my friends at progeeks python class 33 | Hello my friends at progeeks python class 34 | Hello my friends at progeeks python class 35 | Hello my friends at progeeks python class 36 | """ 37 | 38 | # lesson Three homework solution: 39 | 40 | seporators = "+-.,&$^987456314522" 41 | # slow way: 42 | # myfriend = "yoav may maor" 43 | # mylinelist = mylongstr.split('\n') 44 | # mywordlist = mystr.split() 45 | 46 | # better way: 47 | mywordlist = "yoav may maor".split() 48 | 49 | temp_str = "" # temporary string that will be used to build the final string 50 | 51 | for i in range(len(mywordlist)): 52 | if i % 2 != 1: 53 | mystr += mywordlist[i] + " " 54 | 55 | print(mystr) 56 | 57 | # lists: 58 | mylist = [1, 2, 2, '5', 'saba'] # list of different types of data 59 | print(len(mylist)) # length of the list 60 | 61 | maylist = [mylist] # nested list 62 | 63 | print(*maylist) # * unpacks the list 64 | 65 | print(mylist, *mylist, sep="+") # * unpacks the list and prints it 66 | 67 | # * -> dereferance the list 68 | 69 | # iterate over a list: 70 | for i in mylist: 71 | print(i) 72 | 73 | print("----") 74 | 75 | # iterate over a list with index: 76 | for i in range(len(mylist)): 77 | print(mylist[i]) 78 | 79 | print("----") 80 | 81 | 82 | start = 0 83 | stop = len(mystr) 84 | jump = 1 85 | 86 | print(mylist[::-1]) # reverse the list 87 | 88 | print(temp_str[start:stop:jump]) # slice the string 89 | 90 | print(mystr[stop:start:-jump]) # reverce order its like [::-1] 91 | 92 | print(temp_str[::-1]) # reverse the string 93 | -------------------------------------------------------------------------------- /Python43025/Lessons/lessonThree.py: -------------------------------------------------------------------------------- 1 | h, w = "Hello", "World" 2 | symbols = "+-.,&$^987456314522,009)()())(!@#!~@#ADFGSDFG" 3 | 4 | print("#-------IQ level1-----------") 5 | 6 | print("Hello+World") 7 | print("Hello,World") 8 | print("Hello|World") 9 | print("Hello\World") 10 | print("Hello%World") 11 | 12 | print("#-------End IQ level1-----------") 13 | 14 | 15 | print('#-------IQ level2---------------') 16 | 17 | 18 | print(h, w, sep=",") 19 | print(h, w, sep="|") 20 | print(h, w, sep="\\") 21 | print(h, w, sep="END") 22 | print(h, w, sep=' ') 23 | 24 | print("#-------End IQ level2-----------") 25 | 26 | print('#-------IQ level3---------------') 27 | 28 | for i in symbols: 29 | print(h, w, sep=i) 30 | 31 | print("#-------End IQ level3-----------") 32 | 33 | # 1. להכין רשימה של שמות 34 | # 2. ליצור לולאה אשר אומרת בוקר טוב ולילה טוב לכל שם ברשימה 35 | # 3. קודם הוא יגיד לכולם בוקר טוב ואחר כך הוא יגיד לכולם לילה טוב 36 | 37 | # Bonus - > שלב 3 לעשות בלולאה 1 -------------------------------------------------------------------------------- /Python43025/Lessons/lessonTwo.py: -------------------------------------------------------------------------------- 1 | # -- user input -- # 2 | 3 | 4 | name = input("please enter your name: ") 5 | greet = "hello" 6 | thanks = "thank you for joining me!" 7 | print(greet, name, thanks) 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_1.py: -------------------------------------------------------------------------------- 1 | # data types 2 | 3 | # str 4 | 5 | f = "hello worldz" 6 | 7 | second = "Hello World" 8 | 9 | 10 | 11 | f_first_letter = f[0] 12 | 13 | key = 2 14 | 15 | 16 | # allowed values [65 - 90], [97 - 122] 17 | 18 | # Z - 90 19 | # 90 - 65 = 25 20 | # (27 % 25) + 65 = 67 21 | 22 | 23 | encrypt_f = "" 24 | 25 | for index in f: 26 | index_val = ord(index) 27 | range_val = 0 28 | 29 | if index_val >= 65 and index_val <= 90: # Capital letters 30 | range_val = 65 31 | else: # small letters 32 | range_val = 97 33 | 34 | 35 | fixed_val = ((index_val - range_val) + key) % 25 + range_val 36 | 37 | 38 | 39 | 40 | if index_val != 32: 41 | encrypt_f += chr(fixed_val) 42 | else: 43 | encrypt_f += " " 44 | 45 | 46 | 47 | print(encrypt_f) 48 | 49 | 50 | 51 | 52 | 53 | 54 | print(f_first_letter) 55 | 56 | # ord(char) -> ascii value 57 | 58 | # chr(ascii) -> char with given value 59 | 60 | print(ord('a')) 61 | 62 | print(chr(97)) 63 | 64 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_10.py: -------------------------------------------------------------------------------- 1 | x = "hello" 2 | y = "world" 3 | 4 | """ 5 | 1. קבלו קלט מהמשתמש 6 | 2. הוסיפו את האות הראשונה של הקלט לרשימה 7 | 8 | """ 9 | # for xPhone_12123 in range(5): 10 | # print(xPhone_12123) 11 | 12 | 13 | # for jelly in range(5): 14 | # print(jelly) 15 | 16 | 17 | 18 | 19 | 20 | # for i in range(5): 21 | # print("jelly") 22 | 23 | 24 | # print(i) 25 | 26 | 27 | 28 | 29 | 30 | #range(9) מחזיר תווך של מספרים מ 0 - 9 לא כולל 9 31 | 32 | my_list = [] ## יצרנו רשימה ריקה בשם המשתנה my_list 33 | for i in range(5): ## לולאת for רצה חמש פעמים 34 | user_input = input("Enter a word: ") # קולטים קלט מהמשתמש ושומרים אותו בשתנה user_input 35 | mychar = user_input[0] # המשתנה שלנו מחזיק את האות הראשונה מהחרוזת שקיבלנו מהמשתמש! 36 | my_list.append(mychar) # שם את האות הראשונה ששמנו במשתנה מיצ'אר ברשימה שהגרנו קודם 37 | 38 | print(my_list) 39 | 40 | # mylist = [] 41 | # mystr = "Noam" 42 | # mystr2 ="Aviv" 43 | # mylist.append(mystr2) 44 | # mylist.append(mystr) 45 | # print(mylist) 46 | 47 | 48 | """ 49 | בתוך לולאת while 50 | 1. קבלו קלט מהמשתמש 51 | 2. הוסיפו 52 | """ -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_11.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | בתוך לולאת while 4 | 1. קבלו קלט מהמשתמש 5 | 2. הוסיפו אותו לרשימה חיצונית 6 | 3. אם הקלט הוא QUIT צאו מהלולאה 7 | 4. הדפיסו את הרשימה 8 | """ 9 | 10 | # i = 0 11 | # ### True = 1, False = 0 12 | 13 | # x = 10 14 | 15 | # while x: 16 | # print("hello") 17 | # x -= 1 18 | 19 | 20 | 21 | counter = 0 22 | user_input = "" 23 | command_list = [] 24 | while user_input.lower() != "quit": 25 | user_input = input("Please enter you command: ") 26 | if(user_input.lower() == "add"): 27 | amount = input("enter the amount you would like to add") 28 | if amount.isdigit(): 29 | counter += int(amount) 30 | else: 31 | print("can only add integer values") 32 | continue 33 | if(user_input.lower() == "print"): 34 | print(counter) 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | # while(x): 58 | # print(x) 59 | # x += 1 60 | 61 | 62 | 63 | 64 | 65 | # while True: 66 | # print(i) 67 | # if i == 10: 68 | # break 69 | # i += 1 70 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_12.py: -------------------------------------------------------------------------------- 1 | ## lets build a simple calculator 2 | ## we will use the eval() function to evaluate the expression 3 | ## we will use the input() function to get the expression from the user 4 | ## we will use the while loop to keep the program running until the user enters "quit" 5 | ## we will use the if statement to check if the user entered "quit" 6 | 7 | expression = "" 8 | while expression.lower() != "quit": 9 | expression = input("Please enter your expression: ") 10 | 11 | 12 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_13.py: -------------------------------------------------------------------------------- 1 | #import - keyword (להוסיף ספרייה לקוד שלנו) 2 | # import random (ייבא לקוד שלי את כל ספריית ראנדום) 3 | 4 | # pip install {שם הספריה} (אם לא נמצאה הספרייה אפשר להתקין אותה עם השורת פקודה הבאה בטרמינל) 5 | from random import randint 6 | 7 | dice_dict = { 8 | 1:""" 9 | _______ 10 | | | 11 | | | 12 | | o | 13 | | | 14 | |_______|""", 15 | 2:""" 16 | _______ 17 | | | 18 | | o | 19 | | | 20 | | o | 21 | |_______|""", 22 | 3:""" 23 | _______ 24 | | | 25 | | o | 26 | | o | 27 | | o | 28 | |_______|""", 29 | 4:""" 30 | _______ 31 | | | 32 | | o o | 33 | | | 34 | | o o | 35 | |_______|""", 36 | 5:""" 37 | _______ 38 | | | 39 | | o o | 40 | | o | 41 | | o o | 42 | |_______|""", 43 | 6:""" 44 | _______ 45 | | | 46 | | o o | 47 | | o o | 48 | | o o | 49 | |_______|""" 50 | } 51 | 52 | commend = "" 53 | while False: 54 | 55 | # get user input 56 | commend = input("enter a number of dice you would like to roll or quit to exit: ") 57 | 58 | 59 | # exit condition 60 | if commend.lower() == "quit": 61 | print("thanks for playing") 62 | break 63 | 64 | # allowed non-digit first chars 65 | prefix = ["-","+"] 66 | 67 | # check if the user entered a number 68 | if commend.isdigit() or (commend[1:].isdigit() and commend[0] in prefix): 69 | number_of_rolls = abs(int(commend)) 70 | else: 71 | number_of_rolls = 1 72 | 73 | # roll given number of dice 74 | for i in range(number_of_rolls): 75 | dice = randint(1,6) 76 | print(dice_dict[dice], end="") 77 | 78 | 79 | 80 | def dice_builder(n): 81 | #posible 82 | top = " _______ " 83 | botton = "|_______|" 84 | empty = "| |" 85 | mid = "| o |" 86 | two = "| o o |" 87 | left = "| o |" 88 | right = "| o |" 89 | 90 | dice = "" 91 | 92 | dice += top + "\n" + empty + "\n" 93 | match n: 94 | case 1: 95 | dice += empty + "\n" + mid + "\n" + empty + "\n" 96 | case 2: 97 | dice += left + "\n" + empty + "\n" + right + "\n" 98 | case 3: 99 | pass 100 | case 4: 101 | pass 102 | case 5: 103 | pass 104 | case 6: 105 | pass 106 | 107 | dice += botton 108 | 109 | print(dice) 110 | 111 | 112 | dice_builder(2) -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_14.py: -------------------------------------------------------------------------------- 1 | # # varubles & data types 2 | 3 | 4 | # # my friends say "hello" 5 | 6 | # # string 7 | # a = "hello" 8 | # b = 'hello' 9 | # ab = 'my friends say "hello"' 10 | # # boolean 11 | # t = True 12 | # f = False 13 | # # int / float 14 | # n = 5 15 | # fl = 0.5 16 | 17 | # # operator 18 | # """ 19 | # a = 20 | # a + b 21 | # a * b 22 | # a - b 23 | # a ** b 24 | # a % b 25 | # a / b 26 | # a // b 27 | 28 | # a += b a = a + b 29 | # a -= b a = a - b 30 | 31 | # """ 32 | 33 | # # comperators 34 | 35 | # """ 36 | # a > b 37 | # a < b 38 | # a >= b 39 | # a <= b 40 | # a == b 41 | # a != b 42 | # """ 43 | 44 | # # logical operators 45 | 46 | # """ 47 | # not(A) 48 | # A or B -> 49 | # A and B -> 50 | # """ 51 | # # a = 3 52 | # # b = "hello python!" 53 | # # print(a == b or a != b) ## always true! 54 | # # print(a == b and a != b) ## always false! 55 | # # print((not a) or a) ## always true 56 | # # print((not a) and a) ## always false 57 | 58 | 59 | # a = 10 60 | # b = 15 61 | # c = 20 62 | 63 | # if not a > b or b < c: 64 | # print("hey!") 65 | 66 | 67 | # #conditinals 68 | 69 | # # if statment 70 | # condition = a > b 71 | 72 | # condition2 = a + b < b + c 73 | 74 | # if condition: 75 | # print("the condition") 76 | 77 | # # if else statment 78 | # if condition: 79 | # print("c was true") 80 | # else: 81 | # print("c was false") 82 | 83 | # # if elif else statement 84 | 85 | # sun = 10 86 | # moon = "hello world" 87 | 88 | # if condition: 89 | # print("c was true") 90 | # elif condition2: 91 | # print("c2 was true, and c was false") 92 | # elif sun > moon: 93 | # print("goyava") 94 | # elif moon*2 < 3: 95 | # print("banana!!!") 96 | # else: 97 | # print("c & c2 was false") 98 | 99 | 100 | # if condition: 101 | # print("v") 102 | # if condition2: 103 | # print("w") 104 | 105 | # # switch case / match case 106 | # # later 107 | 108 | 109 | # # loops!! 110 | 111 | # # while loops! 112 | 113 | # i = 0 114 | # while i < 10: 115 | # print("heyy!") 116 | # i += 1 117 | 118 | # # for in range() 119 | # start = 0 120 | # stop = 500 121 | # jump = 5 122 | # for i in range(start, stop, jump): 123 | # print(i) 124 | 125 | # # # nested loops 126 | # for i in range(5): # run 5 127 | 128 | # for j in range(5): # 5 x 5 129 | # print(i, j) 130 | 131 | # print("crazyyyyyyy") 132 | 133 | # ## functions !! 134 | 135 | def f(): # function defention 136 | print("a") 137 | print("b") 138 | 139 | # f() # function call! 140 | 141 | # def g(a,b): 142 | # print(a + b) 143 | 144 | # g(5,6) 145 | 146 | # for i in range(5): 147 | # g(i, 5) 148 | 149 | def h(a, b): 150 | return a**b 151 | 152 | x = h(2,2) 153 | print(x) -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_2.py: -------------------------------------------------------------------------------- 1 | 2 | def encrypt(data, key): 3 | encrypt_data = "" 4 | 5 | for index in data: 6 | index_val = ord(index) 7 | range_val = 0 8 | 9 | if index_val >= 65 and index_val <= 90: # Capital letters 10 | range_val = 65 11 | else: # small letters 12 | range_val = 97 13 | 14 | 15 | fixed_val = ((index_val - range_val) + key) % 25 + range_val 16 | 17 | 18 | if index_val != 32: 19 | encrypt_data += chr(fixed_val) 20 | else: 21 | encrypt_data += " " 22 | 23 | return encrypt_data 24 | 25 | 26 | 27 | def decrypt(e_data, key): 28 | decrypt_data = "" 29 | 30 | for index in e_data: 31 | index_val = ord(index) 32 | range_val = 0 33 | 34 | if index_val >= 65 and index_val <= 90: # Capital letters 35 | range_val = 65 36 | else: # small letters 37 | range_val = 97 38 | 39 | 40 | fixed_val = ((index_val - range_val) - key) % 25 + range_val 41 | 42 | 43 | if index_val != 32: 44 | decrypt_data += chr(fixed_val) 45 | else: 46 | decrypt_data += " " 47 | 48 | return decrypt_data 49 | 50 | 51 | 52 | 53 | command = "" 54 | while command != "quit": 55 | command = input("please enter your command: ") 56 | edata = encrypt(command, 2) 57 | print("encrypt :" , edata) 58 | print("decrypt :", decrypt(edata, 2)) 59 | 60 | 61 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_eight.py: -------------------------------------------------------------------------------- 1 | # width = 16 2 | # height = 9 3 | # scaler = 2 4 | # for row in range(height*scaler): 5 | # for col in range(width*scaler): 6 | # print("*", end=" ") 7 | # print() 8 | 9 | # print(height*scaler, width*scaler , height*width) 10 | 11 | """ 12 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 13 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 14 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 15 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 16 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 17 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 18 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 19 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 21 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 22 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 23 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 24 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 25 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 26 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 27 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 28 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 29 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 30 | 31 | """ 32 | 33 | 34 | # size = 10 35 | # for i in range(size): # run 9 times 36 | # for j in range(size): # run 9 x 9 times 37 | # print("0", end=" ") #-> 0 0 0 0 0 0 0 0 0 38 | # print() 39 | 40 | 41 | 42 | 43 | """ 44 | X 0 0 0 0 0 0 0 0 45 | 0 X 0 0 0 0 0 0 0 46 | 0 0 X 0 0 0 0 0 0 47 | 0 0 0 X 0 0 0 0 0 48 | 0 0 0 0 X 0 0 0 0 49 | 0 0 0 0 0 X 0 0 0 50 | 0 0 0 0 0 0 X 0 0 51 | 0 0 0 0 0 0 0 X 0 52 | 0 0 0 0 0 0 0 0 X 53 | """ 54 | 55 | 56 | # size = 9 57 | # for i in range(size): 58 | # for j in range(size): 59 | # if i == j: 60 | # print("X", end=" ") 61 | # else: 62 | # print("0", end=" ") 63 | # print() 64 | 65 | """ 66 | 0 0 0 0 0 0 0 0 0 67 | 0 0 0 0 0 0 0 0 0 68 | 0 0 0 0 0 0 0 0 0 69 | 0 0 0 0 0 0 0 0 0 70 | 0 0 0 0 X 0 0 0 0 71 | 0 0 0 0 0 0 0 0 0 72 | 0 0 0 0 0 0 0 0 0 73 | 0 0 0 0 0 0 0 0 0 74 | 0 0 0 0 0 0 0 0 0 75 | """ 76 | 77 | size = 21 78 | 79 | for i in range(size): 80 | for j in range(size): 81 | if i == j and i == size//2: 82 | print("X", end=" ") 83 | else: 84 | print("0", end=" ") 85 | print() 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | # for jelly in range(9): # run 8 times 94 | # for jam in range(9): # run 8 x 8 times = 64 95 | # if jelly == 0 or jelly == 8 or jam == 0 or jam == 8: 96 | # print("M", end=" ") 97 | # else: 98 | # print("0", end=" ") 99 | # print() 100 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_nine.py: -------------------------------------------------------------------------------- 1 | # counter = 0 2 | # my_var = "AvivAmasterProgrammerInTheMaking" 3 | 4 | # print("the value of counter:", counter) # -> 0 5 | 6 | 7 | 8 | # for i in my_var: 9 | # counter += 1 10 | # print(i, end="\n") 11 | 12 | # print(counter) 13 | 14 | 15 | """ 16 | compartors: 17 | 18 | a == b # is a equal to b? 19 | a != b # is a not equal to b? 20 | a > b # is a greater than b? 21 | a < b # is a less than b? 22 | a >= b # is a greater than or equal to b? 23 | a <= b # is a less than or equal to b? 24 | 25 | 26 | """ 27 | 28 | 29 | data_base = { 30 | "user": "arthuristhking@gmail.com", 31 | "password": "15898201", 32 | } 33 | 34 | 35 | 36 | user = "arthuristhking@gmail.com" 37 | password = "XXXX" # -> 0123456789 38 | # brote force attack 39 | for i in range(10): # -> 0 40 | for j in range(10):# -> 0 41 | for k in range(10):# -> 0,1 42 | for l in range(10): # -> 0,1,2,3,4,5,6,7,8,9 43 | for t in range(10): # -> 0,1,2,3,4,5,6,7,8,9 44 | for y in range(10): # -> 0,1,2,3,4,5,6,7,8, 45 | for u in range(10): 46 | for z in range(10): 47 | password = str(i) + str(j) + str(k) + str(l) + str(t) + str(y) + str(u) + str(z) 48 | if user == data_base["user"] and password == data_base["password"]: 49 | print("Welcome to the system") 50 | 51 | 52 | 53 | # if user == data_base["user"] and password == data_base["password"]: 54 | # print("Welcome to the system") 55 | 56 | 57 | 58 | # print(counter != len(my_var)) 59 | 60 | 61 | # for i in ["python", "lesson"]: 62 | # print("the value of i[0]: ", i[0]) 63 | 64 | 65 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_seven.py: -------------------------------------------------------------------------------- 1 | 2 | ## board 3x3 3 | 4 | ## two players X and O 5 | 6 | ## turn 7 | 8 | """ 9 | 1. create a board & show board 10 | 2. create two players 11 | 12 | while game is not over: 13 | 3. get coordinates from the user 14 | 4. check if the coordinates are valid -> in board bounds and empty 15 | 5. check if the game is over 16 | """ 17 | 18 | 19 | 20 | def create_board(size): 21 | matrix = [] 22 | for row in range(size): 23 | matrix.append([]) 24 | for col in range(size): 25 | matrix[row].append(0) 26 | return matrix ## -> [[0,0,0],[0,0,0],[0,0,0]] 27 | 28 | 29 | 30 | 31 | 32 | def print_board(board): 33 | for row in range(len(board)): 34 | for col in range(len(board[row])): 35 | print(board[row][col], end=" ") 36 | print() 37 | 38 | 39 | def create_players(): 40 | pass 41 | 42 | def get_coordinates(size, board): 43 | x = input("please enter row number: ") 44 | y = input("please enter col number: ") 45 | move = [x,y] 46 | if check_coordinates(size, move, board): 47 | move = [int(x), int(y)] 48 | return move 49 | else: 50 | print("invalid move") 51 | get_coordinates(size, board) 52 | 53 | def check_coordinates(size, move, board): 54 | if move[0].isdigit() and move[1].isdigit(): 55 | if 0 < int(move[0]) <= size and 0 < int(move[1]) <= size: 56 | if board[int(move[0]) - 1][int(move[1]) -1] == 0: 57 | return True 58 | return False 59 | 60 | def insert_move(board, move, player): 61 | board[move[0] -1][move[1] -1] = player 62 | 63 | def check_game_over(): 64 | pass 65 | 66 | 67 | def main(): 68 | size = 3 69 | player1 = 'X' 70 | player2 = 'O' 71 | board = create_board(size) 72 | win = False 73 | counter = 0 74 | while not win: 75 | current_player = player1 if counter % 2 == 0 else player2 76 | print("current player is: ", current_player) 77 | print_board(board) 78 | move = get_coordinates(size, board) 79 | insert_move(board, move, current_player) 80 | counter += 1 81 | 82 | 83 | 84 | """ 85 | 0 0 0 86 | 0 0 0 87 | 0 0 0 88 | 89 | 1. create the algorithm to check for the winner of the game to 90 | 91 | 1: 92 | X X X 93 | 0 0 0 94 | 0 0 0 95 | 96 | 2: 97 | X 0 0 98 | X 0 0 99 | X 0 0 100 | 101 | 3: 102 | X 0 0 103 | 0 X 0 104 | 0 0 X 105 | 106 | plan how to check if one of the conditions are true 107 | 108 | """ 109 | 110 | 111 | board = create_board(3) # board -> [[0,0,0],[0,0,0],[0,0,0]] 112 | for row in range(len(board)): # row -> 0,1,2 run 3 times 113 | print("row is:",row) 114 | for col in range(len(board[row])): # col -> 0,1,2 run 3 x 3 times 115 | print("col is:",col) 116 | for z in range(3): # z -> 0,1,2 run 3 x 3 x 3 times 117 | print("z is:", z) 118 | for w in range(3): # w -> 0,1,2 run 3 x 3 x 3 x 3 times 119 | print("w is:", w) 120 | print() 121 | """ 122 | 123 | """ 124 | 125 | 126 | # for i in range(5): 127 | # for j in range(5): 128 | # print(j) 129 | 130 | 131 | # for i in range(1, 5): # 1,2,3,4 run 4 times 132 | # print(i) 133 | # for j in range(2,7): # 2,3,4,5,6 run 4 x 5 times 134 | # print(j) 135 | 136 | 137 | # for row in range(1,4): # 0 -> n-1 138 | # #print("row is:", row) 139 | # for col in range(1,4): 140 | # #print("col is:", col + row) 141 | # for jelly in range(1,3): 142 | # print("jelly is:", jelly + row + col) 143 | -------------------------------------------------------------------------------- /Python43025/Lessons/lesson_six.py: -------------------------------------------------------------------------------- 1 | # functions with parameters 2 | 3 | 4 | # single line comment (#) 5 | """ 6 | multi line comment(""" """) 7 | """ 8 | 9 | 10 | # a parameter is a variable that is used to pass data into a function 11 | # an argument is the actual value of the variable that is passed to the function 12 | 13 | ## code example 14 | def juicer(fruit="apple"): 15 | print(fruit, 'juice') 16 | 17 | ## the return keyword is used to return a value from a function 18 | def crazy_func(a): # a is a parameter 19 | """ 20 | param a: string 21 | return: string 22 | """ 23 | return a.swapcase() 24 | 25 | def only_even(number): 26 | mylist = [] 27 | for i in range(number): 28 | if i % 2 == 0: 29 | mylist.append(i) 30 | return mylist 31 | 32 | def only_three(given_list): 33 | mylist = [] 34 | for i in given_list: 35 | if i % 3 == 0: 36 | mylist.append(i) 37 | return mylist 38 | 39 | 40 | ## home work 41 | """ 42 | צרו פונקציה שמקבלת מספר ומחזירה רשימה עם כל המספרים שמתחלקים גם ב2 וגם 3 בלי שארית 43 | """ 44 | 45 | 46 | 47 | ## the main function is used to call other functions and to run the program 48 | def main(): 49 | mylist = only_even(100) 50 | list1 = [i for i in range(100)] 51 | 52 | x = only_three(list1) 53 | print(x) 54 | #print(juicer(x)) 55 | #print(crazy_func(x)) # x is the argument that is passed to the function 56 | main() 57 | -------------------------------------------------------------------------------- /Python43025/Lessons/methods.py: -------------------------------------------------------------------------------- 1 | # ## string methods 2 | # # string methods are functions that are called on a string 3 | 4 | # # 1. string.upper() - returns a copy of the string with all the characters in uppercase 5 | # a = "hello" 6 | # b = a.upper() 7 | # print(b) # same as print(a.upper()) 8 | 9 | # # # 2. string.lower() - converts all characters to lowercase 10 | # a = "HELLO" 11 | # print(a.lower()) 12 | 13 | # # # 3. string.title() - capitalizes the first letter of each word 14 | # a = "hello world how are you" 15 | # print(a.title()) 16 | 17 | # # 4. string.capitalize() - capitalizes the first letter of the string 18 | # a = "hello world" 19 | # print(a.capitalize()) 20 | 21 | # # # 5. string.strip() - removes all leading and trailing whitespace 22 | a = " v hello world v " 23 | 24 | 25 | b = "Adam" 26 | c = "A D A M" 27 | d = " Adam " 28 | 29 | # side note ord() -> return the unicode 30 | # print(ord("1")) 31 | 32 | 33 | 34 | # print(len(b)) # 4 35 | # print(len(c)) # 7 36 | # print(len(d)) # 6 37 | # print(b == c) # False 38 | # print(b == d) # False 39 | # print(b == d.strip()) # True 40 | # print(type(b)) ## 41 | 42 | 43 | 44 | # print(a) 45 | # print(a.strip()) 46 | 47 | # 6. string.replace(old, new) - replaces all occurrences of old with new 48 | #string are immutable 49 | # a = "hello world" 50 | # print(a) 51 | # print(a.replace("world", "python")) 52 | 53 | # # # 7. string.split() - splits the string into a list of substrings 54 | # a = "hello world" 55 | # print(a.split()) 56 | 57 | # # 8. string.join(list) - joins the elements in the list into a string 58 | a = ["hello", "world" , "myfriends", "$$$"] 59 | b = "~~~" 60 | # print(b.join(a)) 61 | 62 | # 9. string.find(substring) - returns the index of the first occurrence of substring 63 | a = "Lorem ipsum, dolor sit world amet consectetur adipisicing elit. Enim ipsam sunt et incidunt adipisci rerum perspiciatis quos non ea aut, id assumenda maxime eius a aliquid world possimus doloribus tempore ratione?" 64 | w = "world of great great warcraft great great great great great great war of " 65 | 66 | start = w.find("warraft") 67 | stop = len(w) 68 | print(w[start:stop]) 69 | 70 | -------------------------------------------------------------------------------- /Python43025/Lessons/p.py: -------------------------------------------------------------------------------- 1 | x = 5 2 | y = 7 3 | 4 | def func(a,b): 5 | if(x > y): 6 | print(a + b) 7 | else: 8 | print(a - b) 9 | 10 | 11 | for i in range(10): 12 | print(i) 13 | 14 | 15 | func(x,y) 16 | 17 | 18 | -------------------------------------------------------------------------------- /Python43025/class_notes/loop.py: -------------------------------------------------------------------------------- 1 | 2 | name = "TomPiratinskiy" 3 | 4 | mylist = [1, 2, 3, "MayLindenberg", 5, 6, 7, 8, 9, 10, name, []] 5 | 6 | # for i in name: 7 | # print(name.index(i), i) 8 | 9 | # x = len(name) 10 | # print(x) 11 | 12 | 13 | # number = 50 14 | # for i in range(len(name)): # the range is from 0 to number-1 15 | # print(i) 16 | 17 | 18 | 19 | 20 | 21 | # for i in range(len(mylist)): 22 | # print(mylist[i]) 23 | 24 | # for i in mylist: 25 | # print(i) 26 | 27 | 28 | 29 | 30 | # for i in range(len(name)): 31 | # print(f"the char name[{i}] is: ",name[i]) 32 | 33 | the_alphabet = "abcdefghijklmnopqrstuvwxyz" 34 | 35 | 36 | # start = the_alphabet.index('j') 37 | # stop= the_alphabet.index('u') 38 | 39 | # for i in range(start, stop+1): 40 | # print(the_alphabet[i]) 41 | 42 | 43 | 44 | start = 5 45 | stop = 10 46 | step = 2 47 | 48 | 49 | 50 | for i in range(start, stop, step): 51 | print(the_alphabet[i]) 52 | 53 | -------------------------------------------------------------------------------- /Python43025/static/ASCII-Table-wide.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CheesiePy/PythonLessons/e0f78d2cb10a8f6a78ee8a2fbf25cf612a036bfa/Python43025/static/ASCII-Table-wide.svg.png -------------------------------------------------------------------------------- /Python43025/static/asciifull.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CheesiePy/PythonLessons/e0f78d2cb10a8f6a78ee8a2fbf25cf612a036bfa/Python43025/static/asciifull.gif -------------------------------------------------------------------------------- /PythonLibs/algo.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PythonLibs/mytkinter.py: -------------------------------------------------------------------------------- 1 | # tkinter module 2 | 3 | # import the tkinter module 4 | from tkinter import * 5 | from tkinter import ttk 6 | 7 | # create the root window 8 | root = Tk() 9 | 10 | # create a frame in the window to hold other widgets 11 | frame = ttk.Frame(root, padding=10) 12 | frame.grid() # use the grid geometry manager 13 | 14 | 15 | # 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | #

Python Lesson

2 | 3 | ### This is our Github Page! everything we did in class is right here! 4 | 5 | Lesson so far: 6 | 7 | 1. Data Types and Primitives 8 | 2. Input and Output 9 | 3. Never Repeat Yourself! 10 | 4. Lists and more! 11 | 5. Functions 12 | 13 | -------------------------------------------------------------------------------- /TeacherComment.md: -------------------------------------------------------------------------------- 1 | ## good just ! 2 | --------------------------------------------------------------------------------