├── Buildin functions └── BuildIn_functions.py ├── Class ├── Checkdates.py ├── Class Implementation.py └── Constructor.py ├── Control Structures ├── Desicion Making.py └── Looping.py ├── DataTypes ├── Typecasting.py └── primitive_datatypes.py ├── Exception Handling └── Exceptionhandling.py ├── Functional Programming ├── Lambda_Function.py ├── Recusion.py ├── Square of list values.py └── Sum_of_numbers_Recursion.py ├── Graphs └── 3D-Graphs.py ├── LICENSE ├── List Methods ├── List of char.py ├── Push_Pop_Update.py └── Sorting.py ├── Network Operation ├── ARP.py └── Socket_Programming.py ├── Problems ├── Addition_of_twomatrices.py ├── Area Calculator.py ├── Arithmetics.py ├── Arm Strong Number.py ├── Codebases Problems │ ├── Codebasics Array pb2.py │ ├── Codebasics Array pb3.py │ └── Codebasics Array.py ├── Decimal to Binary.py ├── Factorial Number.py ├── Fibonnaci Series.py ├── Greatest Common Divisor.py ├── Greatest_number.py ├── Guess_Number.py ├── Inverted Triangle pattern.py ├── LCM.py ├── Max_Min.py ├── Multiple Table.py ├── OTPVerifier.py ├── Odd or Even.py ├── Palindrome.py ├── Password Validation.py ├── Random Value Generator.py ├── Replacing letter.py ├── Result Generator.py ├── Simple Compound Interest.py ├── Sum of numbers.py ├── Swapping.py ├── Tallestperson.py ├── Traffic light.py ├── Unitdigit.py ├── screenshootapp.py ├── sum of digits.py └── vowels in list.py ├── README.md ├── String Methods ├── String_Reversing.py └── String_Slicing.py ├── String Patterns └── Hashpattern.py ├── Variables ├── Global_Var.py └── Local_Var.py └── python.jpg /Buildin functions/BuildIn_functions.py: -------------------------------------------------------------------------------- 1 | a=10 2 | b=15 3 | c=a-b 4 | print(abs(c)) 5 | 6 | #chr() 7 | print(chr(255)) 8 | #ord() 9 | print(ord('P')) 10 | 11 | 12 | -------------------------------------------------------------------------------- /Class/Checkdates.py: -------------------------------------------------------------------------------- 1 | import Date 2 | print("To check the individuall is eligible based upon their age") 3 | def main(): 4 | bornbefore=Date(20,5,2000) 5 | dat=prompt() 6 | while dat is not None: 7 | if (dat<=bornbefore): 8 | print("You are eligible") 9 | 10 | 11 | 12 | def prompt(): 13 | month=(int(input("enter month or enter 0 to quit"))) 14 | if (month==0): 15 | return None 16 | else: 17 | day=int(input("Enter date:")) 18 | year=int (input("Enter the year ")) 19 | return Date(month,day,year) 20 | 21 | -------------------------------------------------------------------------------- /Class/Class Implementation.py: -------------------------------------------------------------------------------- 1 | class score: 2 | def __init__(self,Maths,physics,chemistry): 3 | self.Maths=Maths 4 | self.physics=physics 5 | self.chemistry=chemistry 6 | 7 | def result(self): 8 | total=self.Maths+self.physics+self.chemistry 9 | print("Your score is",total) 10 | 11 | 12 | #creating an instance of object by calling class 13 | Ashwin=score(60,30,80) 14 | hari=score(60,80,90) 15 | 16 | Ashwin.result() 17 | hari.result() 18 | -------------------------------------------------------------------------------- /Class/Constructor.py: -------------------------------------------------------------------------------- 1 | class Computer: 2 | def __init__(self,cpu,ram): #Constructor 3 | self.cpu=cpu 4 | self.ram=ram 5 | 6 | 7 | 8 | def config(self): #Method inside class 9 | print("The Configuration",self.cpu,self.ram) 10 | 11 | 12 | 13 | HP=Computer("Intel",8) #instances 14 | Dell=Computer("Intel1",10) 15 | print(id(HP)) 16 | 17 | HP.config() 18 | Dell.config() 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Control Structures/Desicion Making.py: -------------------------------------------------------------------------------- 1 | print("To print the grade for the marks") 2 | n=int(input("Enter the total number of subjects :")) 3 | for i in range(n): 4 | mark=int(input("Enter mark:")) 5 | if(mark>91)and(mark<=100): 6 | print("Congratulations!!! your grade is S") 7 | elif(mark>81)and(mark<=90): 8 | print("Congratulations!!! your grade is A") 9 | elif(mark>71)and(mark<=80): 10 | print("Congratulations!!! your grade is B") 11 | elif(mark>61)and(mark<=70): 12 | print("Congratulations!!! your grade is C") 13 | elif(mark>51)and(mark<=60): 14 | print("Congratulations!!! your grade is D") 15 | elif(mark>0)and(mark<=50): 16 | print("Your are fail and your grade is E") 17 | -------------------------------------------------------------------------------- /Control Structures/Looping.py: -------------------------------------------------------------------------------- 1 | #Lopping staements are used to reduce the writing code 2 | #code to print n natural numbers using for loop 3 | print("To print the n natural numbers") 4 | n=int(input("Enter the total value:")) 5 | count=0 6 | for i in range(n): 7 | count=count+1 8 | print("The values are ,"count) 9 | 10 | 11 | #While 12 | #To print values 13 | n=int(input("Enter the velues to printing")) 14 | i=0 15 | while i<=n: 16 | print("The values are ",i) 17 | 18 | -------------------------------------------------------------------------------- /DataTypes/Typecasting.py: -------------------------------------------------------------------------------- 1 | print("To change the data type of data") 2 | int_data=int(input("Enter the integer data:")) 3 | dec_data=float(input("Enter the decimal data:")) 4 | int_str=str(int_data) 5 | print(int_str) 6 | dec_int=int(dec_data) 7 | print(dec_int) 8 | dec_str=str(dec_data) -------------------------------------------------------------------------------- /DataTypes/primitive_datatypes.py: -------------------------------------------------------------------------------- 1 | """ 2 | python having 6 data types 3 | 1.Number 4 | 2.String 5 | 3.List 6 | 4.Tuple 7 | 5.Set 8 | 6.Dictionary 9 | """ 10 | a=10 11 | print(type(a)) #int 12 | b="PythonScripts" 13 | print(type(b)) #str 14 | c=10.6 15 | print(type(c)) #float 16 | d=[1,2,"3"] 17 | print(type(d)) #List 18 | e=(1,2,3) 19 | print(type(e)) #Tuple 20 | f={5,6,7,8} 21 | print(type(f)) #Set 22 | g={"Name":"PythonScripts","Language":"Python","Repository":"Ash515"} 23 | print(type(g)) #Dictionary 24 | 25 | -------------------------------------------------------------------------------- /Exception Handling/Exceptionhandling.py: -------------------------------------------------------------------------------- 1 | def grade(m1,m2,m3): 2 | try: 3 | grade=(m1+m2+m3)/0 4 | if(grade<90): 5 | print("O") 6 | elif(grade>70 and grade<90): 7 | print("A") 8 | elif(grade>50 and grade <69): 9 | print("B") 10 | else: 11 | print("C") 12 | except: 13 | print("Sorry...please check your calculation") 14 | maths=int(input("Maths mark:")) 15 | physics=int(input("Physics mark:")) 16 | chemistry=int(input("chemistry mark:")) 17 | grade(maths,physics,chemistry) 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Functional Programming/Lambda_Function.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | num=[2,3,4,5,6,7,8,9] 3 | even=list(filter(lambda n:n%2==0,num)) 4 | 5 | print(even) 6 | doubles=list(map(lambda n:n+1,even)) 7 | print(doubles) 8 | red=list(reduce(lambda n:n,doubles)) 9 | print(red) 10 | -------------------------------------------------------------------------------- /Functional Programming/Recusion.py: -------------------------------------------------------------------------------- 1 | print("To print the factorial of given number using recursion") 2 | def factorial(n): 3 | if(n==0): 4 | return -1 5 | else: 6 | return abs(n*factorial(n-1)) 7 | num=int(input("Enter the value:")) 8 | print("The factorial of given number is",factorial(num)) 9 | 10 | 11 | -------------------------------------------------------------------------------- /Functional Programming/Square of list values.py: -------------------------------------------------------------------------------- 1 | print("To print the square values of your list") 2 | def square_list(List): 3 | lst=[] 4 | for i in list: 5 | lst.append(i**2) 6 | return lst 7 | 8 | list=[] 9 | 10 | total=int(input("Enter total number of values:")) 11 | for j in range(total): 12 | values=int(input("Enter the values:")) 13 | list.append(values) 14 | list.sort() 15 | print("Your List is",list) 16 | print("Square values of your list is ",square_list(list)) 17 | -------------------------------------------------------------------------------- /Functional Programming/Sum_of_numbers_Recursion.py: -------------------------------------------------------------------------------- 1 | print("To print the sum of numbers using recursion") 2 | def calculatatesum(num): 3 | if(num): 4 | a=num+calculatatesum(num-1) 5 | return a 6 | else: 7 | return 0 8 | n=int(input("Enter the Number value:")) 9 | print("The Sum of numbers is,",calculatatesum(n)) 10 | -------------------------------------------------------------------------------- /Graphs/3D-Graphs.py: -------------------------------------------------------------------------------- 1 | from mpl_toolkits.mplot3d import axes3d 2 | import matplotlib.pyplot as plt 3 | import numpy as np 4 | def get_test_data(delta=0.05): 5 | from matplotlib.mlab import bivariate_normal 6 | X=500 7 | Y=250 8 | Z=1000 9 | L=3.5 10 | D=2 11 | return X,Y,Z,L,D 12 | fig=plt.figure() 13 | 14 | ax=fig.add_subplot(111,projection='3d') 15 | X,Y,Z=axes3d.get_test_data(0.05) 16 | ax.plot_wireframe(X,Y,Z,rstride=10, cstride=10,color='indigo') 17 | ax.set_xlabel('Backorder items', fontsize=10,color="orange") 18 | ax.set_ylabel('rework rate for \ndefective items',fontsize=10,color="violet") 19 | ax.set_zlabel('Backorder cost\n per item', fontsize=10,color="maroon", rotation = 0) 20 | plt.title('3d Plot-Economic Order Quantity ') 21 | plt.show() 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ashwin Kumar Ramaswamy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /List Methods/List of char.py: -------------------------------------------------------------------------------- 1 | char="python scripts" 2 | result=list(char) 3 | print(result) 4 | # prints ['p','y','t','h','o','n','s','c','r','i','p','t','s'] 5 | -------------------------------------------------------------------------------- /List Methods/Push_Pop_Update.py: -------------------------------------------------------------------------------- 1 | def pop(val): 2 | return pop(val) 3 | 4 | 5 | n=int(input("Enter the total value to be inserted in queue:")) 6 | stack=[] 7 | for i in range(n): 8 | num=int(input("Enter values to be insert:")) 9 | stack.append(num) 10 | print(stack) 11 | print("1.POP 2.PUSH 3.Exit") 12 | choice=int(input("Enter your choice:")) 13 | if(choice==1): 14 | value=int(input("Enter which element you need to delete:")) 15 | val1=value+1 16 | stack.pop(val1) 17 | print(stack) 18 | elif(choice==2): 19 | value2=int(input("Enter the element to be push:")) 20 | position=int(input("Position:")) 21 | stack.insert(position,value2) 22 | print(stack) 23 | else: 24 | exit(1) 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /List Methods/Sorting.py: -------------------------------------------------------------------------------- 1 | print("To sort a list ") 2 | a=[] 3 | size=int(input("size:")) 4 | for i in range(size): 5 | values=int(input("Enter the values: ")) 6 | a.append(values) 7 | a.sort() 8 | print("Your sorted list is",a) 9 | -------------------------------------------------------------------------------- /Network Operation/ARP.py: -------------------------------------------------------------------------------- 1 | print("To find the arp protocols") 2 | IP=["192.108.0.64","192.168.0.60","192.168.0.68","132.147.3.3"] 3 | Ethernet=["0_10_A_u","1_20_L_4","56_3_P_k","O_84_3_9"] 4 | print("Choose your Option: 1.ARP 2.EXIT") 5 | choice=int(input("Enter your choice:")) 6 | if (choice==1): 7 | ipaddr=str(input("Enter your IP adress:")) 8 | for i in IP: 9 | if(ipaddr==i): 10 | print("Your IP address match") 11 | if(ipaddr=="192.108.0.64"): 12 | print("Your Ethernet address is",Ethernet[0]) 13 | elif(ipaddr=="192.168.0.60"): 14 | print("Your Ethernet address is",Ethernet[1]) 15 | elif(ipaddr=="192.168.0.68"): 16 | print("Your Ethernet address is",Ethernet[2]) 17 | elif(ipaddr=="132.147.3.3"): 18 | print("Your Ethernet address is",Ethernet[3]) 19 | else: 20 | print("Bye!!!") 21 | exit(1) 22 | -------------------------------------------------------------------------------- /Network Operation/Socket_Programming.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import * 3 | import socket 4 | import sys 5 | import time 6 | 7 | root=Tk() 8 | root.geometry("500x500") 9 | root.title("Ash-Chat") 10 | def Host(): 11 | s=socket.socket() 12 | host=socket.gethostname() 13 | print("Server will start on host:",host) 14 | port=5005 15 | s.bind((host,port)) 16 | print("Server is bind successfully") 17 | s.listen(5) 18 | conn,addr=s.accept() 19 | print(addr,"has connected") 20 | while 1: 21 | msg=input(str("You:>>")) 22 | msg=msg.encode() 23 | conn.send(msg) 24 | incoming_msg=conn.recv(1024) 25 | incoming_msg=incoming_msg.decode() 26 | print("Client:>>",incoming_msg) 27 | 28 | def server(): 29 | s=socket.socket() 30 | host=input(str("Please enter host name:")) 31 | port=5005 32 | try: 33 | s.connect((host,port)) 34 | print("Connected to server") 35 | except: 36 | print("Connection to server is failed:(") 37 | while 1: 38 | incoming_msg=s.recv(1024) 39 | incoming_msg=incoming_msg.decode() 40 | print("Server:>>",incoming_msg) 41 | msg=input(str("You:>>")) 42 | msg=msg.encode() 43 | s.send(msg) 44 | 45 | 46 | 47 | 48 | 49 | 50 | root.config(bg="pink") 51 | 52 | l=Label(root,text="Chat with Me..",font=('verdana',15,'bold'),bg="black",fg="white") 53 | l.place(x=180,y=10) 54 | text=ScrolledText(root,width=40,height=10) 55 | text['font']=('verdana',10,'bold') 56 | text.place(x=50, y=30) 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | root.mainloop() 73 | -------------------------------------------------------------------------------- /Problems/Addition_of_twomatrices.py: -------------------------------------------------------------------------------- 1 | # Program to add two matrices using nested loop 2 | 3 | X = [[1,2,3], 4 | [4 ,5,6], 5 | [7 ,8,9]] 6 | 7 | Y = [[9,8,7], 8 | [6,5,4], 9 | [3,2,1]] 10 | 11 | 12 | result = [[0,0,0], 13 | [0,0,0], 14 | [0,0,0]] 15 | 16 | # iterate through rows 17 | for i in range(len(X)): 18 | # iterate through columns 19 | for j in range(len(X[0])): 20 | result[i][j] = X[i][j] + Y[i][j] 21 | 22 | for r in result: 23 | print(r) 24 | -------------------------------------------------------------------------------- /Problems/Area Calculator.py: -------------------------------------------------------------------------------- 1 | #Area Calculator 2 | import math 3 | print("Area Calculator") 4 | def Circle(radius): 5 | cir_res=pi*radius*2 6 | return cir_res 7 | def Square(a): 8 | sq_res= 2*a 9 | return sq_res 10 | def Triangle(length,breadth,height): 11 | s=float(length+breadth+height)/2 12 | tri_res=math.sqrt(s*(s-length)*(s-breadth)*(s-height)) 13 | return tri_res 14 | def Rectangle(length,breadth): 15 | rect_res=length*breadth 16 | return rect_res 17 | print("1.Circle 2.Square 3.Rectangle 4.Triangle 5.Exit") 18 | choice=int(input("Enter your choice:")) 19 | if(choice==1): 20 | r=int(input("Enter Radius value:")) 21 | print("Area of Circle is,",Circle(r)) 22 | elif(choice==2): 23 | sq=int(input("Enter radius value:")) 24 | print("Area of Square is,",Square(sq)) 25 | 26 | elif(choice==3): 27 | rec_len=int(input("Enter length:")) 28 | rec_breadth=int(input("Enter Breadth:")) 29 | print("Area of Reactangle is,",Rectangle(rec_len,rec_breadth)) 30 | elif(choice==4): 31 | tri_len=int(input("Enter length:")) 32 | tri_breadth=int(input("Enter Breadth:")) 33 | tri_height=int(input("Enter Height :")) 34 | print("Area of Triangle is,",Triangle(tri_len,tri_breadth,tri_height)) 35 | else: 36 | exit(0) 37 | -------------------------------------------------------------------------------- /Problems/Arithmetics.py: -------------------------------------------------------------------------------- 1 | #Arithmetics 2 | #Addition 3 | def add(a,b,c): 4 | d=a+b+c 5 | return d 6 | res_add=add(10,20,30) 7 | print(res_add) 8 | 9 | #Subtraction 10 | 11 | def sub(a,b,c): 12 | d=a-b-c 13 | return d 14 | res_sub=sub(10,20,30) 15 | print("1.Normal result 2.Absolute result") 16 | choice=int(input("Enter your choice:")) 17 | if(choice=="1"): 18 | print(res_sub) 19 | else: 20 | print(abs(res_sub)) 21 | 22 | #Multiplication 23 | def multiply(n,k): 24 | f=n*k 25 | return f 26 | res_mul=multiply(10,20) 27 | print(res_mul) 28 | 29 | #Division 30 | 31 | def division(m,n): 32 | g=m/n 33 | return g 34 | res_div=print(division(50,10)) 35 | -------------------------------------------------------------------------------- /Problems/Arm Strong Number.py: -------------------------------------------------------------------------------- 1 | #Arm strong number 2 | print("To check wheather the given number is arm strong or not ") 3 | n=int(input("Enter the 3 digt values:")) 4 | val=[int(d) for d in str(n)] 5 | #val=[1,5,3] 6 | c=0 7 | l=[] 8 | for i in val: 9 | c=i**3 10 | 11 | l.append(c) 12 | a=0 13 | for i in l: 14 | a=a+i 15 | 16 | 17 | if(a==n): 18 | print("It is an Arm strong ") 19 | else: 20 | print("not an arm strong") 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Problems/Codebases Problems/Codebasics Array pb2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | You have a list of your favourite marvel super heros. 3 | heros=['spider man','thor','hulk','iron man','captain america'] 4 | Using this find out, 5 | 6 | 1. Length of the list 7 | 2. Add 'black panther' at the end of this list 8 | 3. You realize that you need to add 'black panther' after 'hulk', 9 | so remove it from the list first and then add it after 'hulk' 10 | 4. Now you don't like thor and hulk because they get angry easily :) 11 | So you want to remove thor and hulk from list and replace them with doctor strange (because he is cool). 12 | Do that with one line of code. 13 | 5. Sort the heros list in alphabetical order (Hint. Use dir() functions to list down all functions available in list) 14 | ''' 15 | Heros=['spider man','thor','hulk','iron man','captain america'] 16 | #01 solution 17 | print(len(Heros)) 18 | #02 solution 19 | p=Heros.append('black panther') 20 | print(Heros) 21 | #03 solution 22 | a=Heros.remove(Heros[5]) 23 | b=Heros.insert(3,'black panther') 24 | print(Heros) 25 | #04 solution 26 | c=Heros.remove(Heros[3]) 27 | d=Heros.remove(Heros[4]) 28 | e=Heros.insert(3,'strange') 29 | print(Heros) 30 | #05 solution 31 | h=Heros.sort() 32 | print(Heros) 33 | 34 | -------------------------------------------------------------------------------- /Problems/Codebases Problems/Codebasics Array pb3.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Create a list of all odd numbers between 1 and a max number. Max number is something you need to take from a user using input() function 3 | ''' 4 | max=int(input("Enter the maximum value:")) 5 | arr=[] 6 | for i in range(1,max): 7 | if(i%2!=0): 8 | arr.append(i) 9 | print(arr) 10 | 11 | 12 | -------------------------------------------------------------------------------- /Problems/Codebases Problems/Codebasics Array.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Let us say your expense for every month are listed below, 3 | January - 2200 4 | February - 2350 5 | March - 2600 6 | April - 2130 7 | May - 2190 8 | Create a list to store these monthly expenses and using that find out, 9 | 10 | 1. In Feb, how many dollars you spent extra compare to January? 11 | 2. Find out your total expense in first quarter (first three months) of the year. 12 | 3. Find out if you spent exactly 2000 dollars in any month 13 | 4. June month just finished and your expense is 1980 dollar. Add this item to our monthly expense list 14 | 5. You returned an item that you bought in a month of April and 15 | got a refund of 200$. Make a correction to your monthly expense list 16 | based on this 17 | ''' 18 | Expenses=[2200,2350,2600,2190] 19 | #1 solution 20 | ans1=Expenses[1]-Expenses[0] 21 | print(ans1) 22 | #2 solution 23 | ans2=Expenses[0]+Expenses[1]+Expenses[2] 24 | print(ans2) 25 | #3 solution 26 | for i in range(len(Expenses)): 27 | if(Expenses[i]==2000): 28 | print(i) 29 | else: 30 | pass 31 | 32 | #04 solution 33 | ans3=Expenses.insert(4,1980) 34 | print(Expenses) 35 | #05 solution 36 | ans4=Expenses[3]-200 37 | print(ans4) 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Problems/Decimal to Binary.py: -------------------------------------------------------------------------------- 1 | print("To print decimal to binary") 2 | n=int(input("Enter the value:")) 3 | pos=1 4 | bin=0 5 | while n!=0: 6 | rem=n%2 7 | bin=bin+rem*pos 8 | n=n//2 9 | pos=pos*10 10 | print("Answer:",bin) 11 | 12 | # or we can directly do bin(n) which give the answer 13 | 14 | -------------------------------------------------------------------------------- /Problems/Factorial Number.py: -------------------------------------------------------------------------------- 1 | def fact(num): 2 | factorial=1 3 | if num>=1: 4 | for i in range(1,num+1): # my i values is between 1 to 5 5 | factorial=factorial*i # 6 | print("Factorial is",factorial) 7 | fact(5) 8 | -------------------------------------------------------------------------------- /Problems/Fibonnaci Series.py: -------------------------------------------------------------------------------- 1 | print("To print the fibonacci series") 2 | def fibonacci(n): 3 | a=0 4 | b=1 5 | if(n==0): 6 | print(a) 7 | elif(n<0): 8 | print("Print Positive values") 9 | else: 10 | print(a) 11 | print(b) 12 | for i in range(2,n): 13 | c=a+b 14 | a=b 15 | b=c 16 | print(c) 17 | num=int(input("Enter the Number:")) 18 | fibonacci(num) 19 | -------------------------------------------------------------------------------- /Problems/Greatest Common Divisor.py: -------------------------------------------------------------------------------- 1 | a=int(input("Value:")) 2 | b=int(input("value")) 3 | i=1 4 | while(i<=a and i<=b): 5 | if(a%i==0 and b%i==0): 6 | gcd=i 7 | i=i+1 8 | print("GCD is",gcd) 9 | -------------------------------------------------------------------------------- /Problems/Greatest_number.py: -------------------------------------------------------------------------------- 1 | print("To print a greatest value among given 3 values") 2 | val1=int(input("Enter the 1st value :")) 3 | val2=int(input("Enter the 2st value :")) 4 | val3=int(input("Enter the 3st value :")) 5 | if (val1>val2) and (val1>val3): 6 | print("The value is :",val1) 7 | elif(val2>val1)and(val2>val3): 8 | print("The value is :",val2) 9 | else: 10 | print("The value is :",val3) 11 | -------------------------------------------------------------------------------- /Problems/Guess_Number.py: -------------------------------------------------------------------------------- 1 | print("To guess your number with system magic number") 2 | magic_num=10 3 | user_num=0 4 | 5 | while (user_num!=magic_num): 6 | user_num=int(input("Enter the number between 1 to 10:")) 7 | print("Great! your value {} matched !!!".format(user_num)) 8 | 9 | -------------------------------------------------------------------------------- /Problems/Inverted Triangle pattern.py: -------------------------------------------------------------------------------- 1 | n=int(input("Enter the number:")) 2 | for i in range(n): 3 | print((n-i)*''+i*'*') 4 | -------------------------------------------------------------------------------- /Problems/LCM.py: -------------------------------------------------------------------------------- 1 | def lcm(x,y): 2 | if(x>y): 3 | greater=x 4 | else: 5 | greater=y 6 | while(True): 7 | if(greater%x==0)and(greater%y==0): 8 | lcm=greater 9 | break 10 | greater=greater+1 11 | return lcm 12 | print("LCm of Values",lcm(54,24)) 13 | -------------------------------------------------------------------------------- /Problems/Max_Min.py: -------------------------------------------------------------------------------- 1 | print("To print the maximum and Minimum values in the list") 2 | def Max(array): 3 | print("*****Maximum Values******") 4 | if(array): 5 | array.sort() 6 | print("Your sorted list",array) 7 | Max=max(array) 8 | return Max 9 | else: 10 | return 0 11 | def Min(array): 12 | print("*****Minimum Values******") 13 | if(array): 14 | array.sort() 15 | print("Your sorted list",array) 16 | Min=min(array) 17 | return Min 18 | else: 19 | return 0 20 | ary=[] 21 | total=int(input("Enter the total values into list:")) 22 | for i in range(total): 23 | values=int(input("Enter the list of values:")) 24 | ary.append(values) 25 | print("The Maximum value in your list is",Max(ary)) 26 | print("The Minimum value in your list is",Min(ary)) 27 | -------------------------------------------------------------------------------- /Problems/Multiple Table.py: -------------------------------------------------------------------------------- 1 | n=int(input("Enter the number:")) 2 | for i in range(n): 3 | print(n,"x"i"=",n*i) 4 | -------------------------------------------------------------------------------- /Problems/OTPVerifier.py: -------------------------------------------------------------------------------- 1 | import random 2 | from twilio.rest import Client 3 | 4 | otp=random.randint(1000,9999) 5 | print(otp) 6 | account_sid='Find from your twilio account' 7 | auth_token='Finfd from your twilio account' 8 | client=Client(account_sid,auth_token) 9 | 10 | message=client.message.create( 11 | body='Your OTP is-'+str(otp), 12 | from_='Your trial number', 13 | to='your phone number' 14 | ) 15 | print(message.sid) 16 | -------------------------------------------------------------------------------- /Problems/Odd or Even.py: -------------------------------------------------------------------------------- 1 | print("To print the sum odd values") 2 | n=int(input("Enter the total values:")) 3 | sum=0 4 | for i in range(1,n+1): 5 | if(i%2!=0): 6 | sum-=i 7 | print(sum) 8 | 9 | 10 | -------------------------------------------------------------------------------- /Problems/Palindrome.py: -------------------------------------------------------------------------------- 1 | def palindrome(string): 2 | reverse=string[::-1] 3 | if (reverse==string): 4 | print("It is Palindrome") 5 | else: 6 | print("Not a palindrome") 7 | print("To Check your name is a palindrome or not") 8 | Name=input("Enter the name:") 9 | palindrome(Name) 10 | -------------------------------------------------------------------------------- /Problems/Password Validation.py: -------------------------------------------------------------------------------- 1 | print("To validate a given password is valid or not") 2 | def Validate(password): 3 | special=["!","@","#","$","%",'^',"&","*"] 4 | val=True 5 | if (len(password)<8 ): 6 | print("please enter password size maximum") 7 | val=False 8 | elif not any(char.isdigit() for char in password): 9 | print("Your password not contain numerical value") 10 | val=False 11 | elif not any(char.isupper() for char in password): 12 | print("Your password not contain upper case value") 13 | val=False 14 | elif not any(char.islower() for char in password): 15 | print("Your password not contain lower case value") 16 | val=False 17 | if val: 18 | return val 19 | pwd=input("Enter your password:") 20 | 21 | if(Validate(pwd)): 22 | print("Valid Password !") 23 | else: 24 | print("Not valid password") 25 | 26 | -------------------------------------------------------------------------------- /Problems/Random Value Generator.py: -------------------------------------------------------------------------------- 1 | import random 2 | print("To generate the random values") 3 | x=int(input("Enter the start value:")) 4 | y=int(input("Enter the end value")) 5 | z=random.randint(x,y) 6 | print(z) 7 | -------------------------------------------------------------------------------- /Problems/Replacing letter.py: -------------------------------------------------------------------------------- 1 | def deleteing(string,letter): 2 | for i in string: 3 | if(i==letter): 4 | print(i) 5 | print("your new string is ",string.replace(i,'')) 6 | return 7 | print("No letter found in your string ") 8 | deleteing("Ashwin","A") 9 | 10 | #output - "shwin" 11 | -------------------------------------------------------------------------------- /Problems/Result Generator.py: -------------------------------------------------------------------------------- 1 | print("Ashwin School of Technology (Autonomous)") 2 | print("Department of Examination") 3 | print("CGPA Calculator") 4 | name=input("Enter Name :") 5 | reglist=[] 6 | num=212218205000 7 | while num<=212218205011: 8 | reglist.append(num) 9 | print(reglist) 10 | num=num+1 11 | 12 | if(8 in reglist): 13 | print("value in") 14 | else: 15 | print("not in") 16 | #regno=int(input("enter reg no:")) 17 | # if(regno not in reglist): 18 | # print("wrong value") 19 | # continue 20 | #else:**/ 21 | 22 | 23 | regulation=int(input("Choose your Regulation here: 1.2017\n 2.2019\n")) 24 | if(regulation==1): 25 | Dept=int(input("Select your department:1.IT\n 2.EEE\n 3.CSE\n 4.ECE\n 5.MECH\n 6.EIE\n")) 26 | if(Dept==1): 27 | sem=int(input("Semester :1\n2\n3\n4\n5\n6\n7\n8")) 28 | if(sem==1): 29 | print("Subjects\n") 30 | print("1.English\n2.Mathematics\n3.Physics\n4.Chemistry\n5.Python") 31 | eng=int(input("Enter your English Marks: ")) 32 | maths=int(input("Enter your Mathematics Marks: ")) 33 | phy=int(input("Enter your Physics Marks: ")) 34 | chem=int(input("Enter your Chemistry Marks: ")) 35 | python=int(input("Enter your Python Marks: ")) 36 | total=eng+maths+phy+chem+python 37 | avg=total/5 38 | if(900): 7 | sum+=num 8 | num-=1 9 | print(sum) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Problems/Swapping.py: -------------------------------------------------------------------------------- 1 | print("To Swap a given numbers") 2 | def Two(a,b): 3 | a,b=b,a 4 | return a,b 5 | def Three(x,y,z): 6 | x,y,z=z,y,x 7 | return x,y,z 8 | print("1.Two Numbers 2.Three Numbers 3.Exit") 9 | choice=int(input("Enter your choice:")) 10 | if (choice==1): 11 | val1=int(input("Enter the first value:")) 12 | val2=int(input("Enter the second value:")) 13 | print("Swapping between two values is:",Two(val1,val2)) 14 | elif(choice==2): 15 | val1=int(input("Enter the first value:")) 16 | val2=int(input("Enter the second value:")) 17 | val3=int(input("Enter the third value:")) 18 | print("Swapping between two values is:",Three(val1,val2,val3)) 19 | else: 20 | exit(0) 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Problems/Tallestperson.py: -------------------------------------------------------------------------------- 1 | print("To print the tallest person ") 2 | person1=input("Enter the person name:") 3 | person1_height=input("Enter person1 height:") 4 | person2=input("Enter the person name:") 5 | person2_height=input("Ente person2 height:").format(person2) 6 | if(person1_height>person2_height): 7 | print("The tallest person is",person1) 8 | else: 9 | print("The tallest person is",person2) 10 | 11 | 12 | -------------------------------------------------------------------------------- /Problems/Traffic light.py: -------------------------------------------------------------------------------- 1 | while True: 2 | x = input("Enter value: ") 3 | stop_light = int(x) 4 | if stop_light == 30: 5 | break 6 | elif stop_light >= 1 and stop_light < 10: 7 | print('Green light') 8 | stop_light += 1 9 | elif stop_light < 20: 10 | print('Yellow light') 11 | stop_light += 1 12 | elif stop_light < 30: 13 | print("Red light") 14 | stop_light += 1 15 | else: 16 | stop_light = 0 17 | -------------------------------------------------------------------------------- /Problems/Unitdigit.py: -------------------------------------------------------------------------------- 1 | print("To print the place values of integer") 2 | a=int(input("Enter the integer value:")) 3 | n=a%10 4 | print("The unit digit of {} is{}".format(a,n)) 5 | -------------------------------------------------------------------------------- /Problems/screenshootapp.py: -------------------------------------------------------------------------------- 1 | import pyautogui 2 | import tkinter as tk 3 | 4 | root= tk.Tk() 5 | 6 | canvas1 = tk.Canvas(root, width = 300, height = 300) 7 | canvas1.pack() 8 | 9 | def takeScreenshot (): 10 | 11 | myScreenshot = pyautogui.screenshot() 12 | myScreenshot.save(r'C:\Users\Ron\Desktop\Test\screenshot2.png') 13 | 14 | myButton = tk.Button(text='Take Screenshot', command=takeScreenshot, bg='green',fg='white',font= 10) 15 | canvas1.create_window(150, 150, window=myButton) 16 | 17 | root.mainloop() 18 | -------------------------------------------------------------------------------- /Problems/sum of digits.py: -------------------------------------------------------------------------------- 1 | n=123 2 | num=[int(d) for d in str(n)] 3 | a=0 4 | for i in num: 5 | a=a+i 6 | print(a) 7 | 8 | #output: 6 9 | -------------------------------------------------------------------------------- /Problems/vowels in list.py: -------------------------------------------------------------------------------- 1 | name="asowin" 2 | new_names=list(name) 3 | vowel="aeiou" 4 | new_vowels=list(vowel) 5 | res=[] 6 | for i in new_names: 7 | for j in new_vowels: 8 | if(i==j): 9 | res.append(i) 10 | print(res) #['a', 'o', 'i'] 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PythonScripts 2 | One great place to all pyscripts 👨‍💻👩‍💻 3 | 4 | - Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. 5 | - Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. 6 | - Python supports modules and packages, which encourages program modularity and code reuse. 7 | 8 | ## 💛 Prerequisites 9 | Python IDE install it by using this link [python.org](https://www.python.org/) 10 | 11 | ## 🚀 Installation 12 | 1. Clone the repository 13 | ``` 14 | https://github.com/Ash515/PythonScripts.git 15 | ``` 16 | 2. Check the status of your file 17 | ``` 18 | $git status 19 | ``` 20 | 21 | 3.For using VScode for editing your files 22 | ``` 23 | $git code . 24 | ``` 25 | 4. To directly add your files to github 26 | ``` 27 | $git add . 28 | ``` 29 | 5. After writing your code commit your changes 30 | ``` 31 | $git commit -m 32 | ``` 33 | 6. To pull your code to reposoitory 34 | ``` 35 | $git push origin master 36 | ``` 37 | Thats all about installation and version control with **Git** 38 | 39 | ## Contribution 40 | - Fork this repository . 41 | - Make pull requests with proper commit message. 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /String Methods/String_Reversing.py: -------------------------------------------------------------------------------- 1 | print("To print the reverse of list") 2 | python=[100,50,40,30,20,10,5] 3 | rev=python[::-1] 4 | print(rev) 5 | 6 | -------------------------------------------------------------------------------- /String Methods/String_Slicing.py: -------------------------------------------------------------------------------- 1 | s="Ashwin Kumar" 2 | str=[s[i:j] 3 | for i in range(len(s)) 4 | for j in range (i+1,len(s)+1)] 5 | print(s) 6 | -------------------------------------------------------------------------------- /String Patterns/Hashpattern.py: -------------------------------------------------------------------------------- 1 | print("To print the star pattern style") 2 | length=6 3 | for i in range(length+1): 4 | print(i * '*'+(length-i)*"#") 5 | -------------------------------------------------------------------------------- /Variables/Global_Var.py: -------------------------------------------------------------------------------- 1 | a=10 #Normal initialization of object to variable a 2 | def global_var(): 3 | global a #declaring that a variable as a global variable here to access or use that a here 4 | a=a+1 # calculation 5 | print(a) 6 | global_var() #calling the function 7 | 8 | """ 9 | output become 11 10 | """ 11 | """ 12 | Global variables for Nested functions 13 | """ 14 | def func_out(): 15 | x=10 16 | def func_in(): 17 | global x 18 | x=20 19 | print(x) 20 | func_in() 21 | 22 | 23 | """ 24 | output 20 25 | Because here we already declare x=10 to func_out() so there is no need to make that x as global in 26 | func_in(). 27 | """ 28 | #globals() 29 | 30 | t= 100 31 | def func(): 32 | list_of_items = globals() 33 | list_of_items["t"] = 15 34 | t = 22 35 | print("Local value of t is:", t) 36 | print("The value of t is:", t) 37 | func() 38 | print("Change in the value of t is:", t) 39 | 40 | -------------------------------------------------------------------------------- /Variables/Local_Var.py: -------------------------------------------------------------------------------- 1 | def local_var(): 2 | a=10 # Initializing local variable a inside the function 3 | a=a+1 #calculation 4 | print(a) 5 | local_var() #calling the function 6 | 7 | """ 8 | Output become 11 9 | """ -------------------------------------------------------------------------------- /python.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ash515/PyScripts/5a9b64bb8383c553f0fb3996a107cabfd25feff3/python.jpg --------------------------------------------------------------------------------