├── Projects_H.W ├── targil1_hw.py ├── targil2_hw.py ├── targil13_hw.py ├── targil3_hw.py ├── targil8_hw.py ├── targil14_hw.py └── targil6_hw.py ├── README.md ├── Lesson1 ├── targil3.py ├── targil4.py ├── targil1.py ├── targil5.py ├── targil2.py ├── targil7.py ├── rand_tmp.py ├── targil6.py └── targil8.py ├── Project_H.W2 ├── targil8.py ├── targil10.py ├── targil14.py ├── targil18.py ├── targil1.py └── targil149.py ├── Lesson4 ├── main_code.py └── defim.py ├── Lesson3 ├── filehand3.py ├── filehand2.py ├── filehand.py ├── new.py └── file_project.py ├── Lesson2 ├── Fuction4.py ├── Function2.py ├── Function3.py └── Function1.py └── Labs ├── LAB1.py ├── LAB3.py ├── LAB5.py ├── LAB4.py ├── LAB2.py ├── LAB7.py ├── LAB6.py ├── LAB9.py └── LAB8.py /Projects_H.W/targil1_hw.py: -------------------------------------------------------------------------------- 1 | print("Net4U, is the best place\n …in the world") -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python_digital 2 | This is my python_digital course 3 | 4 | 5 | -------------------------------------------------------------------------------- /Projects_H.W/targil2_hw.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | print(datetime.datetime.now()) -------------------------------------------------------------------------------- /Lesson1/targil3.py: -------------------------------------------------------------------------------- 1 | ##Lists 2 | 3 | my_list=["google","facebook","ebay","apple"] 4 | print("net4u" in my_list) -------------------------------------------------------------------------------- /Projects_H.W/targil13_hw.py: -------------------------------------------------------------------------------- 1 | list=[1,2,3,4,5,6,7] 2 | 3 | sum=0 4 | for i in range(len(list)): 5 | sum=sum+list[i] 6 | 7 | print(sum) -------------------------------------------------------------------------------- /Projects_H.W/targil3_hw.py: -------------------------------------------------------------------------------- 1 | # idan hakimi 2 | # 3 | # i m i k a h n a d i 4 | 5 | a=input("Enter full name: ") 6 | print(' '.join(a[::-1])) 7 | 8 | -------------------------------------------------------------------------------- /Projects_H.W/targil8_hw.py: -------------------------------------------------------------------------------- 1 | n = 20 2 | d = {"x":200} 3 | l = [1,3,5] 4 | 5 | 6 | print(type(n)()) 7 | print(type(d)()) 8 | print(type(l)()) 9 | -------------------------------------------------------------------------------- /Projects_H.W/targil14_hw.py: -------------------------------------------------------------------------------- 1 | list=['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] 2 | 3 | list.pop(5) 4 | list.pop(4) 5 | list.pop(0) 6 | print(list) -------------------------------------------------------------------------------- /Project_H.W2/targil8.py: -------------------------------------------------------------------------------- 1 | color_list = ["Red", "Green", "White", "Black"] 2 | 3 | print("The first cell: " + color_list[0] + "\nThe last cell: " + color_list[-1]) -------------------------------------------------------------------------------- /Projects_H.W/targil6_hw.py: -------------------------------------------------------------------------------- 1 | num=int(input("Enter a number: ")) 2 | 3 | if(num%2==0): 4 | print("This number is even\n") 5 | else: 6 | print("This number is odd") -------------------------------------------------------------------------------- /Lesson1/targil4.py: -------------------------------------------------------------------------------- 1 | ##dictionary 2 | 3 | my_dict={"www.google.com":"8.8.8.8","www.facebook.com":"7.7.7.7","www.youtube.com":"www.google2.com"} 4 | print("www.google2.com" in my_dict.values()) -------------------------------------------------------------------------------- /Lesson1/targil1.py: -------------------------------------------------------------------------------- 1 | name=input("Enter your name: ") 2 | age=input("Enter your Age: ") 3 | mail=input("Enter your mail: ") 4 | 5 | print("\nFull name: " + name + "\nYour Age is: " + str(age) + "\nYour mail: " + mail) 6 | 7 | -------------------------------------------------------------------------------- /Lesson1/targil5.py: -------------------------------------------------------------------------------- 1 | ##conditions 2 | 3 | name=input("Enter your name: \n") 4 | age=int(input("Enter your age: \n")) 5 | if((name=="idan" or name=="Idan") and (age>=18)): 6 | print("You can enter to the club!") 7 | else: 8 | print("You are not allowed to enter...") -------------------------------------------------------------------------------- /Lesson4/main_code.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | from time import sleep 3 | from Lesson4.defim import menu,calculating,dogs_age 4 | 5 | 6 | menu() 7 | sleep(3) 8 | print("wow!\n") 9 | calculating(3,6) 10 | dogs_age(int(input("Enter dog's age: "))) 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Project_H.W2/targil10.py: -------------------------------------------------------------------------------- 1 | '''Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn 2 | Sample value of n is 5 3 | Expected Result : 615''' 4 | 5 | 6 | 7 | 8 | n=int(input("Enter a number: ")) 9 | print(n + (n*10+n) + (n*100+n*10+n)) 10 | 11 | 12 | -------------------------------------------------------------------------------- /Lesson3/filehand3.py: -------------------------------------------------------------------------------- 1 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/hello.txt" 2 | file = open(filename, "r") 3 | print(file.readlines()[2]) 4 | file.close() 5 | ######################### 6 | ##Create a empty file 7 | # f = open("C:/Users/אידן חכימי/Documents/Pycharm/NET4U.txt", "x") 8 | # f.close() 9 | -------------------------------------------------------------------------------- /Lesson1/targil2.py: -------------------------------------------------------------------------------- 1 | # print("p1={},p2={},p3={},p4={}".format(1,1.0,"idan","BBFD")) 2 | 3 | # print("idan hakimi" in "Hello idan hakimi,\nWe recieved your mail...") 4 | # a="idan hakimi" 5 | print("idanha" in a) 6 | 7 | s1="ABCDEF" 8 | print(s1[::-1]) 9 | # print(s1[2::2]) 10 | # print(s1[::-1]) 11 | -------------------------------------------------------------------------------- /Lesson1/targil7.py: -------------------------------------------------------------------------------- 1 | while(True): 2 | name=input("Enter a name: ") 3 | if(name=="idan"): 4 | print("Hello Idan") 5 | break 6 | elif(name=="ben"): 7 | continue 8 | else: 9 | print("WHere is Idan?") 10 | 11 | number=int(input("Enter a numer:")) 12 | print(number*4) 13 | 14 | print("Bye Bye...") -------------------------------------------------------------------------------- /Project_H.W2/targil14.py: -------------------------------------------------------------------------------- 1 | '''Write a Python program to calculate number of days between two dates. 2 | Sample dates : (2014, 7, 2), (2014, 7, 11) 3 | Expected output : 9 days 4 | ''' 5 | 6 | from datetime import date 7 | f_date = date(2014, 6, 2) 8 | print(f_date) 9 | l_date = date(2014, 7, 11) 10 | print(l_date) 11 | delta = l_date - f_date 12 | print(delta.days) -------------------------------------------------------------------------------- /Project_H.W2/targil18.py: -------------------------------------------------------------------------------- 1 | '''Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum.''' 2 | 3 | 4 | def sum_thrice(x, y, z): 5 | sum = x + y + z 6 | 7 | if(x == y == z): 8 | sum = sum * 3 9 | return sum 10 | 11 | 12 | print(sum_thrice(1, 2, 3)) 13 | print(sum_thrice(3, 3, 3)) -------------------------------------------------------------------------------- /Lesson2/Fuction4.py: -------------------------------------------------------------------------------- 1 | def add_ip(ip1,ip2,ip3): 2 | list=[] 3 | list.append(ip1) 4 | list.append(ip2) 5 | list.append(ip3) 6 | return list 7 | 8 | 9 | ip_list=[] 10 | ip_n1=input("Enter first IP: ") 11 | ip_n2=input("Enter 2nd IP: ") 12 | ip_n3=input("Enter 3rd IP: ") 13 | ip_list=add_ip(ip_n1,ip_n2,ip_n3) 14 | ip_list=add_ip(ip_n1,ip_n2,ip_n3) 15 | print(ip_list) -------------------------------------------------------------------------------- /Lesson1/rand_tmp.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | from time import sleep 3 | 4 | print("Getting random numbers...\n") 5 | sleep(3) 6 | num1=randint(1,37) 7 | num2=randint(1,37) 8 | print("1st number: " + str(num1) + "\n2nd number: " + str(num2) + "\n") 9 | 10 | if (num1==num2): 11 | print("You won 100$ \n") 12 | else: 13 | print("You won 0 $\n") 14 | 15 | print("Bye Bye\n") -------------------------------------------------------------------------------- /Project_H.W2/targil1.py: -------------------------------------------------------------------------------- 1 | #"Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" 2 | 3 | 4 | print('''Twinkle, twinkle, little star, 5 | How I wonder what you are! 6 | Up above the world so high, 7 | Like a diamond in the sky. 8 | Twinkle, twinkle, little star, 9 | How I wonder what you are''') 10 | -------------------------------------------------------------------------------- /Lesson2/Function2.py: -------------------------------------------------------------------------------- 1 | # def calculating(): 2 | # num1=int(input("Enter a number: ")) 3 | # num2 = int(input("Enter a number: ")) 4 | # print("Your new number is: " + str(num1*num2)) 5 | # 6 | # calculating() 7 | 8 | def calcuating2(x,y): 9 | print("Your first number: " + str(x) + " \nYour second number: " + str(y)) 10 | print("\nYour new number is: " + str(x**y)) 11 | 12 | 13 | a=int(input("Enter a number: ")) 14 | b=int(input("Enter a number: ")) 15 | calcuating2(a,b) -------------------------------------------------------------------------------- /Lesson1/targil6.py: -------------------------------------------------------------------------------- 1 | ##For loops 2 | from time import sleep 3 | 4 | print("Now we will get all the details about your class:\n-------------------------------------\n") 5 | for i in range(2): 6 | name=input("Enter a name: ") 7 | age=int(input("Enter an age:")) 8 | phone=input("Enter a phone:") 9 | print("Printing student number " + str(i+1) + " Details...\n") 10 | sleep(3) 11 | print("Full name: " + name + "\nAge: " + str(age) + "\nPhone: " + phone + "\n--------------------\n") 12 | 13 | 14 | print("\nBye Bye") -------------------------------------------------------------------------------- /Labs/LAB1.py: -------------------------------------------------------------------------------- 1 | num=int(input("Enter a number with 4 digits: ")) 2 | ''' 3 | Alafim=4 4 | Meot=5 5 | Asarot=6 6 | Ahadot=7 7 | ''' 8 | #This is Alafim 9 | # print("Alafim=" + str(num//1000)) 10 | # 11 | # #This is Meot 12 | # print("Meot=" + str((num%1000)//100)) 13 | # 14 | # #This is Asarot 15 | # print("Asarot=" + str((num%100)//10)) 16 | # 17 | # #This is Ahadot 18 | # print("Ahadot=" + str(num%10)) 19 | 20 | print("Alafim=" + str(num//1000) + "\nMeot=" + str((num%1000)//100) + "\nAsarot=" + str(((num%100)//10)) + "\nAhadot=" + str((num%10)) ) 21 | -------------------------------------------------------------------------------- /Lesson3/filehand2.py: -------------------------------------------------------------------------------- 1 | # filename = "C:/Users/אידן חכימי/Documents/Pycharm/hello.txt" 2 | # file = open(filename, "r") 3 | # my_string=file.read() 4 | # file.close() 5 | # print(my_string) 6 | # my_list=my_string.split(",") 7 | # print(type(my_list)) 8 | # print(my_list) 9 | 10 | 11 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/hello.txt" 12 | file = open(filename, "r") 13 | # print(file.readlines()[2]) 14 | new_list=[] 15 | new_list=file.read().splitlines() 16 | print(new_list) 17 | file.close() 18 | for i in new_list: 19 | print("Available " + i) 20 | -------------------------------------------------------------------------------- /Lesson4/defim.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | def calculating(a,b): 4 | c=int(input("Enter a number: ")) 5 | sum=a*b*c 6 | print("The sum is: " + str(sum)) 7 | 8 | 9 | def dogs_age(a): 10 | print("Real Dog's age: " + str(a*7)) 11 | return a*7 12 | 13 | 14 | def menu(): 15 | choice=input("Menu:\n1.Printing 1-100\n2.random 2 cubes") 16 | if(choice=="1"): 17 | for i in range(1,101): 18 | print(i) 19 | elif(choice=="2"): 20 | print("Cube 1: " + str(randint(1,6))) 21 | print("Cube 2: " + str(randint(1, 6))) 22 | else: 23 | print("1-2 only!!...") 24 | 25 | -------------------------------------------------------------------------------- /Lesson2/Function3.py: -------------------------------------------------------------------------------- 1 | # def calculating(): 2 | # num1=int(input("Enter a number: ")) 3 | # num2 = int(input("Enter a number: ")) 4 | # sum=num1*num2 5 | # print("Your new number is: " + str(sum)) 6 | # return sum 7 | # 8 | # 9 | # a=calculating()+29 10 | # print("WOW:" + str(a)) 11 | 12 | def calcuating2(x,y): 13 | print("Your first number: " + str(x) + " \nYour second number: " + str(y)) 14 | sum=x**y 15 | print("\nYour new number is: " + str(sum)) 16 | return sum 17 | 18 | 19 | a=int(input("Enter a number: ")) 20 | b=int(input("Enter a number: ")) 21 | idan=calcuating2(a,b) + 29 22 | print("WOW:" + str(idan)) -------------------------------------------------------------------------------- /Project_H.W2/targil149.py: -------------------------------------------------------------------------------- 1 | '''Write a Python function that takes a positive integer and 2 | returns the sum of the cube of all the positive integers smaller than the specified number.''' 3 | 4 | # def positive(num): 5 | # sum=0 6 | # for i in range(1,num): 7 | # sum=sum+(i**3) 8 | # print("The Summary is: " + str(sum)) 9 | # return sum 10 | # 11 | # 12 | # new_sum=positive(int(input("Enter a positive number: "))) 13 | 14 | 15 | 16 | 17 | def sum_of_cubes(n): 18 | n = n-1 19 | total = 0 20 | while n > 0: 21 | total =total+( n * n * n) 22 | n = n-1 23 | return total 24 | 25 | print("Sum of cubes: " + str(sum_of_cubes(7))) 26 | 27 | -------------------------------------------------------------------------------- /Labs/LAB3.py: -------------------------------------------------------------------------------- 1 | '''Create 2 variables : string of your full name, another string of your mail. 2 | Create variable of your age (integer) 3 | print all of them to the screen 4 | 5 | then Print your name from the end to the beginning and print it only with your age*3 6 | 7 | then check if your name is stored inside this full string: 8 | "idan ben dudu yuval shimon yael gal adam shahar yana" 9 | ''' 10 | name="idan hakimi" 11 | age=28 12 | mail="idan@gmail.com" 13 | print("Full name: " + name + "\nage: " + str(age) + "\nmail: " + mail) 14 | print("\n\nFull name: " + name[::-1] + "\nage: " + str(age*3) ) 15 | print("elia" in "idan ben dudu yuval shimon yael gal adam shahar yana") 16 | -------------------------------------------------------------------------------- /Labs/LAB5.py: -------------------------------------------------------------------------------- 1 | '''Create a dictionary with 5 names & money 2 | then sum the money of the first & last names and print it to the screen 3 | after, add a new name with the sum of the money you calculated before 4 | in the end, print the number of entries and check if "idan" is inside 5 | ''' 6 | 7 | dict_names={"dudu":25000,"avi":30000,"itay":76000,"ortal":66000,"gal":120000} 8 | print(dict_names) 9 | summay=dict_names["dudu"]+dict_names["gal"] 10 | print("The summary is: " + str(summay)) 11 | # dict_names["yoel"]=summay 12 | # print(dict_names) 13 | dict_names.update({"yoel":summay}) 14 | print(dict_names) 15 | print("Number of entries: " + str(len(dict_names))) 16 | print("idan" in dict_names) -------------------------------------------------------------------------------- /Labs/LAB4.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Create a list with 4 details about you: name, age, mail, phone and print it to the screen 3 | then create another list with 2 IPs , then add 3 more IPs , pop the 3rd IP and print how many 4 | IPs do we have and print them. 5 | ''' 6 | 7 | details_list=["Idan Hakimi" , 28 , "idan@gmail.com" , "0234234342"] 8 | print("Full name: " + details_list[0] + "\nAge: " + str(details_list[1]) + "\nMail: " + details_list[2] + "\nPhone: " + details_list[3]) 9 | ip_list=["1.1.1.1","2.2.2.2"] 10 | print(ip_list) 11 | ip_list.append("3.3.3.3") 12 | ip_list.append("4.4.4.4") 13 | ip_list.append("5.5.5.5") 14 | print(ip_list) 15 | ip_list.pop(2) 16 | print("IP List length is: " + str(len(ip_list)) + "\nAnd the IP list: " + str(ip_list)) -------------------------------------------------------------------------------- /Labs/LAB2.py: -------------------------------------------------------------------------------- 1 | print("Now we will calculate your marketing:\n\nPrices:\n----------\nTomato=3 NIS\nCucamber=2 NIS\nCola=5 NIS\nChicken=20 NIS\n ") 2 | tomatos=int(input("Enter how many tomatos?")) 3 | cucambers=int(input("Enter how many cucamberss?")) 4 | colas=int(input("Enter how many colas?")) 5 | chickens=int(input("Enter how many chickens?")) 6 | 7 | print("\nSummary of your order:\n-----------\ntomatos: " + str(tomatos) + "\ncucambers: " + str(cucambers) + "\ncolas: " + str(colas) + "\nchickens: " + str(chickens)) 8 | 9 | summary=(tomatos*3)+(cucambers*2)+(colas*5)+(chickens*20) 10 | print("\nYou have to pay: " + str(summary) + " NIS without tax") 11 | print("\nYou have to pay: " + str("%.2f" % (summary*1.17)) + " NIS with tax") 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Lesson2/Function1.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | from time import sleep 3 | 4 | ################################## 5 | def Market(): 6 | print("Now we will calculate your marketing:\n\nPrices:\n----------\nTomato=3 NIS\nCucamber=2 NIS\nCola=5 NIS\nChicken=20 NIS\n ") 7 | tomatos=int(input("Enter how many tomatos?")) 8 | cucambers=int(input("Enter how many cucamberss?")) 9 | colas=int(input("Enter how many colas?")) 10 | chickens=int(input("Enter how many chickens?")) 11 | 12 | print("\nSummary of your order:\n-----------\ntomatos: " + str(tomatos) + "\ncucambers: " + str(cucambers) + "\ncolas: " + str(colas) + "\nchickens: " + str(chickens)) 13 | 14 | summary=(tomatos*3)+(cucambers*2)+(colas*5)+(chickens*20) 15 | print("\nYou have to pay: " + str(summary) + " NIS without tax") 16 | print("\nYou have to pay: " + str("%.2f" % (summary*1.17)) + " NIS with tax") 17 | 18 | ################################### 19 | #####Main code########## 20 | for i in range(10): 21 | Market() -------------------------------------------------------------------------------- /Lesson3/filehand.py: -------------------------------------------------------------------------------- 1 | #‘r’ – Read mode which is used when the file is only being read 2 | #‘w’ – Write mode which is used to edit and write new information to the file (any existing files with the same name will be erased when this mode is activated) 3 | #‘a’ – Appending mode, which is used to add new data to the end of the file; that is new information is automatically amended to the end 4 | #‘r+’ – Special read and write mode, which is used to handle both actions when working with a file 5 | 6 | ###write 192.168.1.1/1.2 7 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/hello.txt" 8 | file = open(filename, "r+") 9 | print(file.read()) 10 | file.write("192.168.1.1\n192.168.1.2") 11 | print(file.read()) 12 | file.close() 13 | # 14 | # ###it will append 192.168.1.3/1.4 15 | # file = open(filename, "a+") 16 | # file.write("\n192.168.1.3\n192.168.1.4") 17 | # file.close() 18 | # 19 | # ###print to the screen the new output of the file 20 | # file = open(filename, "r") 21 | # print(file.read()) 22 | # file.close() 23 | # 24 | # filename = "C:/Users/אידן חכימי/Documents/Pycharm/hello.txt" 25 | # file = open(filename, "r") 26 | # for line in file: 27 | # print(line) 28 | # file.close() 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Labs/LAB7.py: -------------------------------------------------------------------------------- 1 | ''' Lab7- Cube project 2 | נקבל כקלט כמה כסף יש לנו לשחק 3 | עלות משחק 3 ש"ח 4 | אם יש עוד נחזיר אותו ללקוח 5 | בכל תור נגריל 2 קוביות , אם הן זהות זכינו ב- 100 ש"ח, אם הן זהות אבל שוות גם ל-6, זכינו ב- 1000 ש"ח 6 | אם הן לא זהות, אבל קוביה 2 שווה ל-2 זכינו ב- 40 ש"ח 7 | אם הן לא זהות אבל קוביה 1 שווה ל-1 זכינו ב- 20 ש"ח 8 | לבסוף נדפיס למסך בכמה כסף זכינו 9 | ''' 10 | 11 | from random import randint 12 | from time import sleep 13 | 14 | print("Welcome to our Cube game\nEach turn cost 3 ILS\n") 15 | money=int(input("Enter how much money do you have?\n ")) 16 | turns=(money//3) 17 | print("You have: " + str(turns) + " turns\nYour change: " + str(money%3) + " ILS\n") 18 | prize=0 19 | for i in range(turns): 20 | print("Rolling Cubes for Round Number " + str(i+1) + " :\n------------------------") 21 | sleep(3) 22 | cube1=randint(1,6) 23 | cube2=randint(1,6) 24 | print("Cube1: " + str(cube1) + "\nCube2: " + str(cube2) + "\n") 25 | if(cube1==cube2): 26 | if(cube1==6): 27 | prize=prize+1000 28 | else: 29 | prize=prize+100 30 | elif(cube1==1): 31 | prize = prize + 20 32 | elif(cube2==2): 33 | prize = prize + 40 34 | 35 | print("Calculating your prize...") 36 | sleep(3) 37 | print("Your prize: " + str(prize) + " ILS") -------------------------------------------------------------------------------- /Labs/LAB6.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | choice=input("Menu:\n-----\n1.Insert Number and ** it by 3\n2.Insert 4 IPs to a list and print it\n3.Insert 4 Entries to DNS_Dictionary and print it\n4.Check if a string is Polindrom\n") 4 | if(choice=="1"): 5 | print("The new number is: " + str((int(input("Enter a number: ")))**3)) 6 | elif(choice=="2"): 7 | list_ip=[] 8 | list_ip.append(input("Enter new IP: ")) 9 | list_ip.append(input("Enter new IP: ")) 10 | list_ip.append(input("Enter new IP: ")) 11 | list_ip.append(input("Enter new IP: ")) 12 | print("\nThe new list:\n--------------\n" + str(list_ip )) 13 | elif(choice=="3"): 14 | dns_dict={} 15 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 16 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 17 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 18 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 19 | print("\nThe new dns_dict:\n--------------\n" + str(dns_dict)) 20 | elif(choice=="4"): 21 | word=input("Enter a word: ") 22 | if (word == word[::-1]): 23 | print("This is polindrom!") 24 | else: 25 | print("This isn't polindrom!") 26 | else: 27 | print("Enter 1-4 only!!...") 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Lesson3/new.py: -------------------------------------------------------------------------------- 1 | def create_file(file): 2 | f = open("C:/Users/אידן חכימי/Documents/Pycharm/" + file + ".txt" , "x") 3 | f.close() 4 | 5 | def read_file(file): 6 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/" + file 7 | file = open(filename, "r") 8 | print(file.read()) 9 | file.close() 10 | 11 | def write_file(file): 12 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/" + file 13 | file = open(filename, "w") 14 | file.write(input("Enter IP: ") + "\n" + input("Enter IP: ")) 15 | file.close() 16 | 17 | def append_file(file): 18 | filename = "C:/Users/אידן חכימי/Documents/Pycharm/" + file 19 | file = open(filename, "a") 20 | file.write(input("Enter IP: ") + "\n" + input("Enter IP: ")) 21 | file.close() 22 | 23 | def menu(): 24 | while(True): 25 | choice=input("Enter your choice:\n1.Create a file\n2.Read a file\n3.Write a file\n4.Append to a file\n") 26 | if(choice=="1"): 27 | create_file(input("Enter file name: ")) 28 | elif(choice=="2"): 29 | read_file(input("Enter file name: ")) 30 | elif(choice=="3"): 31 | write_file(input("Enter file name: ")) 32 | elif(choice=="4"): 33 | append_file(input("Enter file name: ")) 34 | else: 35 | print("fuck off") 36 | 37 | 38 | ########Main Code########## 39 | menu() -------------------------------------------------------------------------------- /Labs/LAB9.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Menu: 3 | 1.Dogs Details 4 | 2.Friends list 5 | 3.N Azzeret 6 | ''' 7 | from random import randint 8 | from time import sleep 9 | 10 | def menu(): 11 | while(True): 12 | choice=input("Menu:\n--------------\n1.Dogs Details\n2.Friends list\n3.N Azzeret\n") 13 | if(choice=="1"): 14 | Dogs() 15 | elif(choice=="2"): 16 | Friends() 17 | elif(choice=="3"): 18 | Azzeret() 19 | else: 20 | print("Enter 1-3 only!!!\n") 21 | continue 22 | exit=input("Do you want to exit? yes/no\n") 23 | if(exit=="yes"): 24 | break 25 | else: 26 | print("Welcome back\n") 27 | print("Bye Bye\n") 28 | 29 | 30 | def Dogs(): 31 | name=input("Enter Dog's name: ") 32 | age=int(input("Enter dog's age: ")) 33 | print("\nDog's Name: " + name + "\nDog's age: " + str(age*7) + "\n") 34 | 35 | 36 | def Friends(): 37 | list_friends=[] 38 | for i in range(5): 39 | list_friends.append(input("Enter a firend's name: ")) 40 | name=input("Enter new name: ") 41 | if(name in list_friends): 42 | print(name + " is inside the list!!\n") 43 | else: 44 | print(name + " isn't inside the list\n") 45 | 46 | def Azzeret(): 47 | num=int(input("Enter a number: ")) 48 | sum=1 49 | for i in range(1,num+1): 50 | sum=sum*i 51 | print(str(num) + " Azzeret is: " + str(sum) + "\n") 52 | 53 | 54 | menu() -------------------------------------------------------------------------------- /Lesson1/targil8.py: -------------------------------------------------------------------------------- 1 | ##while loops 2 | from time import sleep 3 | 4 | while(True): 5 | choice=input("Menu:\n-----\n1.Insert Number and ** it by 3\n2.Insert 4 IPs to a list and print it\n3.Insert 4 Entries to DNS_Dictionary and print it\n4.Check if a string is Polindrom\n") 6 | if(choice=="1"): 7 | print("The new number is: " + str((int(input("Enter a number: ")))**3)) 8 | elif(choice=="2"): 9 | list_ip=[] 10 | list_ip.append(input("Enter new IP: ")) 11 | list_ip.append(input("Enter new IP: ")) 12 | list_ip.append(input("Enter new IP: ")) 13 | list_ip.append(input("Enter new IP: ")) 14 | print("\nThe new list:\n--------------\n" + str(list_ip )) 15 | elif(choice=="3"): 16 | dns_dict={} 17 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 18 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 19 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 20 | dns_dict.update({input("Enter a URL: "): input("Enter IP: ")}) 21 | print("\nThe new dns_dict:\n--------------\n" + str(dns_dict)) 22 | elif(choice=="4"): 23 | word=input("Enter a word: ") 24 | if (word == word[::-1]): 25 | print("This is polindrom!") 26 | else: 27 | print("This isn't polindrom!") 28 | else: 29 | print("Enter 1-4 only!!...\n") 30 | 31 | exit=input("Do you want to exit? y/n\n") 32 | if(exit=="y" or exit=="yes"): 33 | break 34 | else: 35 | print("Welcome back!\n") 36 | 37 | 38 | print("Thank you and bye bye") 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Labs/LAB8.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Menu: 3 | 1. printing 100 numbers 4 | 2. check fibo 5 | 3. randint numbers until we get 12 or we count 10 times 6 | ''' 7 | from random import randint 8 | from time import sleep 9 | 10 | while(True): 11 | choice=input("Menu:\n--------------\n1.printing 100 numbers\n2.check fibo\n3.randint numbers until we get 12 or we count 10 times\n") 12 | ######################################################## 13 | if(choice=="1"): 14 | for i in range(1,101): 15 | print(i) 16 | ######################################################## 17 | elif(choice=="2"): 18 | #fibo = [1, 2, 3, 5, 8, 13, 21] 19 | fibo=[] 20 | for i in range(7): 21 | fibo.append(int(input("Enter a number: "))) 22 | boolean = "True" 23 | for i in range(2, len(fibo)): 24 | print(fibo[i]) 25 | print(fibo[i - 1]) 26 | print(fibo[i - 2]) 27 | print("\n") 28 | if fibo[i] != (fibo[i - 1] + fibo[i - 2]): 29 | boolean = "False" 30 | break 31 | if boolean == "True": 32 | print("It is fibo series") 33 | else: 34 | print("It isn't fibo series") 35 | ######################################################## 36 | elif(choice=="3"): 37 | counter = 1 38 | num=randint(1,12) 39 | while(num!=12 and counter<11): 40 | print("Counter:" + str(counter) + " Number:" + str(num) + "\n") 41 | counter=counter+1 42 | num = randint(1, 12) 43 | else: 44 | print("Enter 1-3 only!!\n") 45 | continue 46 | exit=input("Do you want to exit? yes/no\n") 47 | if(exit=="yes"): 48 | print("Thank you and bye bye...\n") 49 | break 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Lesson3/file_project.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | ################################################## 4 | def menu(list_ip): 5 | while(True): 6 | choice=input("\nMenu:\n---------\n1. Create a new file\n2. add new IP address\n3. remove specific IP address\n4. search for an IP\n5. print specific IP\n6. print all IPs\n") 7 | if(choice=="1"): 8 | create_file() 9 | elif(choice=="2"): 10 | list_ip=add_IP(list_ip) 11 | elif(choice=="3"): 12 | list_ip=remove_ip(list_ip) 13 | elif(choice=="4"): 14 | search_ip(list_ip) 15 | else: 16 | print("Enter 1-6 only!!!!\n") 17 | continue 18 | if(input("\nDo you want to quit? y/n")=="y"): 19 | break 20 | else: 21 | print("\nWelcome back\n") 22 | print("\nBye Bye\n") 23 | ############################################################## 24 | def create_file(): 25 | print("Creating file...\n") 26 | 27 | ############################################################## 28 | def add_IP(list_ip): 29 | new_ip=search_ip(list_ip) 30 | if(new_ip!=False): 31 | print("\nAdding new IP...\n") 32 | sleep(3) 33 | list_ip.append(new_ip) 34 | print("Your new List of IPs: " + str(list_ip)) 35 | return list_ip 36 | 37 | ############################################################## 38 | def search_ip(list_ip): 39 | new_ip=input("Enter IP: ") 40 | print("\nSearching...\n") 41 | sleep(3) 42 | if(new_ip in list_ip): 43 | print("This IP is already in use!") 44 | return False 45 | else: 46 | print("This IP is available") 47 | return new_ip 48 | 49 | ############################################################## 50 | def remove_ip(list_ip): 51 | ip=search_ip(list_ip) 52 | if(ip==False): 53 | print("\nDeleting the IP...\n") 54 | sleep(3) 55 | list_ip=list_ip.remove(ip) 56 | print("The new list: " + str(list_ip)) 57 | else: 58 | print("\nThis IP doesn't exist...\n") 59 | return list_ip 60 | 61 | 62 | ##########main code############### 63 | my_list=["192.168.1.1","1.1.1.1","55.55.55.55"] 64 | menu(my_list) --------------------------------------------------------------------------------