Skip to content

Commit 6e2b66a

Browse files
committed
all python files
0 parents  commit 6e2b66a

34 files changed

+664
-0
lines changed

.idea/Mypython.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Bubble_sort.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def sort(nums):
2+
for i in range(len(nums)-1,0,-1):
3+
for j in range(i):
4+
if nums[j]> nums[j+1]:
5+
temp=nums[j]
6+
nums[j]=nums[j+1]
7+
nums[j+1]=temp
8+
9+
10+
11+
nums=[2,7,21,75,1]
12+
print("unsorted list:\n",nums)
13+
sort(nums)
14+
print("sorted list using Bubble sort\n",nums)

Decorators_example1.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def new_decorator(original_func):
2+
3+
def wrap_func():
4+
print('Some extra code before the original function')
5+
6+
original_func()
7+
8+
print('some extra code after original function')
9+
return wrap_func()
10+
11+
@new_decorator
12+
def func_need_decorator():
13+
print('I WANT TO BE A DECORATOR')
14+
15+
func_need_decorator()

EnumPython.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Simple python program to implement enum
2+
from enum import Enum
3+
class Cricket(Enum):
4+
T20 = 20
5+
ODI = 50
6+
TEST = 90
7+
IPL = 20
8+
9+
print("Is IPL considered as T20 ?")
10+
print(Cricket.IPL==Cricket.T20)
11+
print ("Is ODI match same as TEST match?")
12+
print(Cricket.ODI==Cricket.TEST)
13+

Generators_example1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from random import randint
2+
def lottery():
3+
# returns 6 numbers between 20 and 40
4+
for i in range(6):
5+
yield randint(20, 40)
6+
7+
# returns a 7th number between 1 and 15 and then again a number between 1 and 2
8+
yield randint(1,15)
9+
yield randint(1, 2)
10+
for random_number in lottery():
11+
print("And the next number is... %d" %(random_number))

MyData

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hello my name is ajay
2+

Pig_latinProgram.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def pig_latin(word):
2+
first_letter = word[0]
3+
if first_letter in 'aeiou':
4+
pig_word = word+ 'ay'
5+
else:
6+
pig_word = word[1:] + first_letter + 'ay'
7+
8+
return pig_word
9+
10+
word = input("Enter the word: ")
11+
res =pig_latin(word)
12+
print(f'Pig Latin format for {word} is {res}')

PrimeNum.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To find prime number in a given range
2+
3+
start = int(input("Start: "))
4+
end = int(input("End: "))
5+
for i in range(start, end +1):
6+
7+
# if number is divisible by any number between 2 and i it is not prime
8+
if i >1 :
9+
for j in range(2,i):
10+
if(i%j)==0:
11+
break
12+
else:
13+
print(i)

Selection_sort.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def sort(nums):
2+
for i in range(5):
3+
mi
4+
5+
6+
7+
nums=[3,4,,7,42,2,11,32,22,1]
8+
9+
print("unsorted list ",nums)
10+
sort=(nums)
11+
12+
print("sorted list ",nums)

SimpleInterest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#To calculate simple interest given principle amount, time and rate of interest
2+
3+
p = float(input("Enter the principle amount: "))
4+
t = float(input("Enter the time(yrs): "))
5+
r = float(input("Enter the rate of interest: "))
6+
# to find simple interest multiple all three values and divide by 100
7+
SI = (p * r * t)/100
8+
print(f"Simple Interest is : {SI}")

SingleStringlst.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
lst = ['Ajay ' , 'Santosh ' , 'Gaonkar' ]
2+
print(lst)
3+
4+
#using inbuilt join function
5+
print("".join(lst))
6+
7+
8+
# using for loop
9+
for i in range(len(lst)):
10+
print(lst[i],end="")

Thread_prg.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from time import sleep
2+
from threading import *
3+
class Hello(Thread):
4+
def run(self):
5+
for i in range(5):
6+
print("hello")
7+
sleep(1)
8+
9+
10+
class Hi(Thread):
11+
def run(self):
12+
for i in range(5):
13+
print('hi')
14+
sleep(1)
15+
16+
t1=Hello()
17+
t2=Hi()
18+
19+
t1.start()
20+
sleep(0.2)
21+
t2.start()
22+
23+
t1.join()
24+
t2.join()
25+
print("bye")

add.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Adding of two numbers
2+
3+
num1 = input("Enter First number: ")
4+
num2 = input("Enter second number: ")
5+
6+
sum = float(num1) + float(num2) #user might also enter float nmubers
7+
print(f'The sum of {num1} + {num2} = {sum}') #using f function
8+
print("The sum of {0} + {1} = {2} ".format(num1,num2,sum))#using format for print

0 commit comments

Comments
 (0)