Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b408834

Browse files
committed
Merge branch 'master' of https://github.com/bgoonz/PYTHON_PRAC
2 parents 03589b7 + 5c28dd8 commit b408834

File tree

584 files changed

+30491
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

584 files changed

+30491
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def complementary():
2+
while(True):
3+
complementary = float(input('Complementary of : '))
4+
if complementary <= 90:
5+
complement = 90 - complementary
6+
return(complement)
7+
break
8+
else:
9+
print('Number greater than 90 degree. Try again')
10+
continue
11+
12+
def supplementary():
13+
while(True):
14+
supplementary = float(input('Supplementary of : '))
15+
if supplementary <= 180:
16+
supplement = 180 - supplementary
17+
return(supplement)
18+
break
19+
else:
20+
print('Number greater than 180 degree. Try again')
21+
continue
22+
23+
while(True):
24+
countOrEnd = str(input('Count or End : '))
25+
if countOrEnd.strip() == 'Count':
26+
print('\nSupp for supplementary\nComp for complementary')
27+
getSuppOrCom = str(input('Supp or Comp : '))
28+
if getSuppOrCom.strip() == 'Supp':
29+
print(supplementary())
30+
continue
31+
elif getSuppOrCom.strip() == 'Comp':
32+
print(complementary())
33+
continue
34+
else:
35+
break
36+
else:
37+
quit()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# average of sum of lists
2+
m = [1,43,656,8,54,908,4,5,23,78,435,89,45,476,89]
3+
n = [234,56,90,675,56,786,90,564,8,657,87,64,354,2,75]
4+
q = [34,76,76,564,34,32,16,67,25,98,90,345,235,64,134,76]
5+
6+
def avgSums():
7+
summingUp = sum(m) + sum(n) + sum(q)
8+
summed = summingUp / 3
9+
return(summed)
10+
11+
print(avgSums)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# piggy bank
2+
# pre code
3+
money = 0
4+
5+
# function to add money to current amount
6+
def addMoney():
7+
print(" ")
8+
userAdd = float(raw_input("Add money : "))
9+
print(" ")
10+
money = money + userAdd
11+
print("After adding current Money you have is " + str(money) + " rupees")
12+
13+
# function to withdraw money from current amount
14+
def withdrawMoney():
15+
print(" ")
16+
userWithdraw = float(raw_input("Add money : "))
17+
print(" ")
18+
money = money + userWithdraw
19+
print("After adding current Money you have is " + str(money) + " rupees")
20+
21+
# function to display current amount
22+
def currentMoney():
23+
print(" ")
24+
current = "Current money you have is " + str(money) + " rupees"
25+
26+
# main code
27+
print(" ")
28+
print("--------------------Start-------------------")
29+
while True:
30+
print(" ")
31+
user = raw_input("Start or End : ")
32+
if user.strip() == "Start":
33+
controlPiggy = raw_input("Add Withdraw or Check : ")
34+
if controlPiggy.strip() == "Add":
35+
print(addMoney())
36+
continue
37+
elif controlPiggy.strip() == "Withdraw":
38+
print(withdrawMoney())
39+
continue
40+
elif controlPiggy.strip() == "Check":
41+
print(currentMoney())
42+
continue
43+
else :
44+
print(" ")
45+
print("Invalid Input.Try again")
46+
continue
47+
48+
elif user.strip() == "End" :
49+
print(" ")
50+
print("------------Program Ended-----------")
51+
print(" ")
52+
break
53+
54+
else :
55+
print(" ")
56+
print("Invalid Input. Try again")
57+
continue
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Percentage Calculator
2+
def percentToOrig():
3+
whatPercent = float(input('What Percent : '))
4+
ofWhat = float(input('Of What Percent : '))
5+
orignal = whatPercent / 100 * ofWhat
6+
print(orignal)
7+
8+
print(percentToOrig())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import smtplib
2+
3+
# REMEMBER : dont send mails through public computers or servers
4+
5+
# connecting to googles serevrs
6+
serverToLogin = smtplib.SMTP('smtp.gmail.com' , 587)
7+
# Username
8+
userName = str(input('Username for Gmail : '))
9+
# password
10+
password = str(input('Password Of Account : '))
11+
# Logging in
12+
serverToLogin.login(userName , password)
13+
14+
def sendMail():
15+
yourEmail = str(input('Your Email Address : ')) # senders email address
16+
toSendEmail = str(input('Receivers Email Address')) # receivers email address
17+
messageHead = str(input('Message Head : ')) # Message head
18+
messageBody = str(input('Message : ')) # main message
19+
fullMessage = messageHead + '\n' + messageBody # full message
20+
serverToLogin.sendmail(yourEmail , toSendEmail , fullMessage) # sending email address through server
21+
22+
while True:
23+
toSendOrNot = str(input('Send or End : '))
24+
if toSendOrNot == 'Send':
25+
print('\n')
26+
print(sendMail())
27+
else :
28+
quit()
29+
30+
31+
32+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Creating tuples
2+
# Tuples are used to store 2-d grids and fixed values
3+
# tuples are immutable that means they cant be changed
4+
5+
tupA = () # Empty tuple
6+
print(tupA)
7+
8+
c = 12,56,78
9+
10+
tupC = tuple(c) # tuple() is built-in
11+
print(tupC)
12+
13+
x,y,z = (12,45,42)
14+
15+
a = x,y,z
16+
print(a)
17+
print(type(a))
18+
19+
# Accessing items in tuples
20+
print(tupC[0])
21+
print(a[1])
22+
print(tupC[2],'\n')
23+
24+
# tuples cant be reassigned
25+
# tupC[1] = 18 # uncomment this line to see the error this should cause a error 'TypeError'
26+
27+
# iterating through tuples
28+
for x in tupC:
29+
print(x)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reading files
2+
3+
# Enter file name which is in same directory as that of the program
4+
fileName = str(input('File name : '))
5+
fileToRead = open(fileName, 'r') # 'r' reads the file
6+
print(fileToRead.read()) # reading file
7+
fileToRead.close() # closing the file
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# functions to sort out data
2+
# they act on lists
3+
# you can apply these functions in your programs
4+
5+
# this function takes first and second element from list and compare them
6+
def bubbleSort(g): # g argument is for list
7+
for x in range(len(g) - 2):
8+
a = g[x]
9+
b = g[x + 1 + 1]
10+
if a > b :
11+
return(a)
12+
else :
13+
return(b)
14+
# use this to convert output into list
15+
# result = list(map(bubbleSort , g)) replace g with parameter
16+
17+
# this function checks even num
18+
def oddSort(odd):# odd can be list or variable
19+
for x in odd:
20+
if x % 3 == 0:
21+
return(x)
22+
# use this to get list as output
23+
# result = list(filter(oddSort , odd)) replace odd with parameter
24+
25+
# this function checks even num
26+
def evenSort(eve):# eve can be list or variable
27+
for a in eve:
28+
if a % 2 == 0:
29+
return(a)
30+
# use this to get list as output
31+
# result = list(filter(evenSort , eve)) replace eve with parameter
32+
33+
# this function checks divisibility
34+
def divisibleSort(divi , get):# here divi is list and get is an variable set to integer or float
35+
for r in divi:
36+
if r % get == 0:
37+
return(r)
38+
# use this to get output
39+
# result = list(filter(divisibleSort , divi , get)) replace arguments with suitable parameters
40+
41+
# this function checks if addition of group of two elements has desired answer
42+
def addBubbleSort(f,user):# here f is list and user is integer or float
43+
for x in range(len(f) - 2):
44+
a = f[x]
45+
b = f[x + 1 + 1]
46+
if a + b == user:
47+
return(a,b)
48+
# i havent checked this function check for bugs
49+
# this is how it works
50+
# res = list(filter(addBubbleSort , f , user)) replace arguments with suitable parameters
51+
52+
# this function checks if subtraction of group of two elements has desired answer
53+
def subBubbleSort(z,userSub):
54+
for x in range(len(z) - 2):
55+
a = z[x]
56+
b = z[x + 1 + 1]
57+
if a - b == useSubr:
58+
return(a,b)
59+
# i havent checked this function check for bugs
60+
#res = list(filter(subBubbleSort , z , userSub)) replace arguments with suitable parameters
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# string indexing
2+
3+
'''
4+
Indexing
5+
0 1 2 3 4
6+
H E L L O
7+
'''
8+
9+
message = 'Hello'
10+
print(message[0]) # this will print H that is first letter in the string
11+
print(message[1:4]) # this will print from index one to index four
12+
print(message[:3]) # this will print from starting to index 3
13+
print(message[2:]) # this will print from index 2 till end
14+
print(message[:]) # this prints whole string
15+
print(message[0:4:2]) # this escapes 2 characters from string
16+
17+
# negative Indexing
18+
'''
19+
negative Indexing
20+
P y t h o n
21+
-6 -5 -4 -3 -2 -1
22+
'''
23+
24+
awesome = 'Python is awesome'
25+
print(awesome[:-1]) # -1 prints last character
26+
print(awesome[-2]) # this prints m from starting
27+
print(awesome[-7:]) # try this one out in interpreter
28+
29+
print('You are ' + awesome[10:] + ' you are learning ' + awesome[:6])
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import platform
2+
import os
3+
import sys
4+
5+
print('============================')
6+
print('System Information : ')
7+
print(os.name)
8+
print(platform.system())
9+
print(platform.release(),'\n')
10+
print('============================')
11+
print('Python Version Installed : ')
12+
print(sys.version,'\n')
13+
print('============================')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /