Skip to content

Commit f70a757

Browse files
authored
Merge pull request #1 from geekcomputers/master
Merge with fork
2 parents 3dfdfaa + 8682a38 commit f70a757

File tree

217 files changed

+108574
-493
lines changed

Some content is hidden

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

217 files changed

+108574
-493
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import cmath
2+
3+
a = 1
4+
b = 5
5+
c = 6
6+
7+
# calculate the discriminant
8+
d = (b**2) - (4*a*c)
9+
10+
# find two solutions
11+
sol1 = (-b-cmath.sqrt(d))/(2*a)
12+
sol2 = (-b+cmath.sqrt(d))/(2*a)
13+
14+
print('The solution are {0} and {1}'.format(sol1,sol2))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Solve the quadratic equation ax**2 + bx + c = 0
2+
3+
# import complex math module
4+
import cmath
5+
6+
a = 1
7+
b = 5
8+
c = 6
9+
10+
# calculate the discriminant
11+
d = (b**2) - (4*a*c)
12+
13+
# find two solutions
14+
sol1 = (-b-cmath.sqrt(d))/(2*a)
15+
sol2 = (-b+cmath.sqrt(d))/(2*a)
16+
17+
print('The solution are {0} and {1}'.format(sol1,sol2))

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
.idea
22
*.pyc
3+
string=sorted(input())
4+
lower=""
5+
even=""
6+
odd=""
7+
upper=""
8+
for i in string:
9+
if i.islower():
10+
lower+=i
11+
elif i.isupper():
12+
upper+=i
13+
elif int(i)%2==0:
14+
even+=i
15+
else:
16+
odd+=i
17+
print(lower+upper+odd+even)

12

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import turtle
2+
t = turtle.Turtle()
3+
t.circle(20)
4+
t1=turtle.Turtle()
5+
t1.circle(25)

56

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
t = turtle.Turtle()
2+
t.circle(50)
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""
2+
Problem:
3+
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor
4+
of a given number N?
5+
6+
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
7+
"""
8+
9+
10+
def solution(n: int) -> int:
11+
def solution(n: int = 600851475143) -> int:
12+
"""Returns the largest prime factor of a given number n.
13+
>>> solution(13195)
14+
29
15+
>>> solution(10)
16+
5
17+
>>> solution(17)
18+
17
19+
>>> solution(3.4)
20+
3
21+
>>> solution(0)
22+
Traceback (most recent call last):
23+
...
24+
ValueError: Parameter n must be greater or equal to one.
25+
>>> solution(-17)
26+
Traceback (most recent call last):
27+
...
28+
ValueError: Parameter n must be greater or equal to one.
29+
>>> solution([])
30+
Traceback (most recent call last):
31+
...
32+
TypeError: Parameter n must be int or passive of cast to int.
33+
>>> solution("asd")
34+
Traceback (most recent call last):
35+
...
36+
TypeError: Parameter n must be int or passive of cast to int.
37+
"""
38+
try:
39+
n = int(n)
40+
except (TypeError, ValueError):
41+
raise TypeError("Parameter n must be int or passive of cast to int.")
42+
if n <= 0:
43+
raise ValueError("Parameter n must be greater or equal to one.")
44+
45+
i = 2
46+
ans = 0
47+
48+
if n == 2:
49+
return 2
50+
51+
while n > 2:
52+
while n % i != 0:
53+
i += 1
54+
55+
ans = i
56+
57+
while n % i == 0:
58+
n = n / i
59+
60+
i += 1
61+
62+
return int(ans)
63+
64+
65+
if __name__ == "__main__":
66+
# print(solution(int(input().strip())))
67+
import doctest
68+
69+
doctest.testmod()
70+
print(solution(int(input().strip())))

ABC

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Python3 program to add two numbers
2+
3+
number1 = input("First number: ")
4+
number2 = input("\nSecond number: ")
5+
6+
# Adding two numbers
7+
# User might also enter float numbers
8+
sum = float(number1) + float(number2)
9+
10+
# Display the sum
11+
# will print value in float
12+
print("The sum of {0} and {1} is {2}" .format(number1, number2, sum))

ARKA

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def sumOfSeries(n):
2+
x = (n * (n + 1) / 2)
3+
return (int)(x * x)
4+
5+
6+
7+
# Driver Function
8+
n = 5
9+
print(sumOfSeries(n))

Add two numbers

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
patch-1
2+
# This program adds two numbers
3+
4+
num1 = 1.5
5+
num2 = 6.3
6+
7+
# Add two numbers
8+
sum = num1 + num2
9+
10+
# Display the sum
11+
=======
12+
num1 = 1.5
13+
num2 = 6.3
14+
15+
16+
sum = num1 + num2
17+
18+
master
19+
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

Area of triangle

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
a = 5
2+
b = 6
3+
c = 7
4+
# a = float(input('Enter first side: '))
5+
# b = float(input('Enter second side: '))
6+
# c = float(input('Enter third side: '))
7+
8+
# calculate the semi-perimeter
9+
s = (a + b + c) / 2
10+
11+
# calculate the area
12+
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
13+
print('The area of the triangle is %0.2f' %area)

Armstrong number

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
num=int(input("enter 1-digit number:"))
2+
f=num
3+
sum=0
4+
while (f>0):
5+
a=f%10
6+
f=int(f/10)
7+
sum=sum+(a**3)
8+
if(sum==num):
9+
print("it is an armstrong number:",num)
10+
else:
11+
print("it is not an armstrong number:",num)
12+

Assembler/GUIDE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guide for Python-Assembler
1+
# Guide for Python_Assembler
22

33
### Register
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#The project automates calls for people from the firebase cloud database and the schedular keeps it running and checks for entries
2+
#every 1 hour using aps scedular
3+
#The project can be used to set 5 min before reminder calls to a set of people for doing a particular job
4+
import os
5+
from firebase_admin import credentials, firestore, initialize_app
6+
from datetime import datetime,timedelta
7+
import time
8+
from time import gmtime, strftime
9+
import twilio
10+
from twilio.rest import Client
11+
#twilio credentials
12+
acc_sid=""
13+
auth_token=""
14+
client=Client(acc_sid, auth_token)
15+
16+
#firebase credentials
17+
#key.json is your certificate of firebase project
18+
cred = credentials.Certificate('key.json')
19+
default_app = initialize_app(cred)
20+
db = firestore.client()
21+
database_reference = db.collection('on_call')
22+
23+
#Here the collection name is on_call which has documents with fields phone , from (%H:%M:%S time to call the person),date
24+
25+
#gets data from cloud database and calls 5 min prior the time (from time) alloted in the database
26+
def search():
27+
28+
calling_time = datetime.now()
29+
one_hours_from_now = (calling_time + timedelta(hours=1)).strftime('%H:%M:%S')
30+
current_date=str(strftime("%d-%m-%Y", gmtime()))
31+
docs = db.collection(u'on_call').where(u'date',u'==',current_date).stream()
32+
list_of_docs=[]
33+
for doc in docs:
34+
35+
c=doc.to_dict()
36+
if (calling_time).strftime('%H:%M:%S')<=c['from']<=one_hours_from_now:
37+
list_of_docs.append(c)
38+
print(list_of_docs)
39+
40+
while(list_of_docs):
41+
timestamp=datetime.now().strftime('%H:%M')
42+
five_minutes_prior= (timestamp + timedelta(minutes=5)).strftime('%H:%M')
43+
for doc in list_of_docs:
44+
if doc['from'][0:5]==five_minutes_prior:
45+
phone_number= doc['phone']
46+
call = client.calls.create(
47+
to=phone_number,
48+
from_="add your twilio number",
49+
url="http://demo.twilio.com/docs/voice.xml"
50+
)
51+
list_of_docs.remove(doc)
52+
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#schedular code for blocking schedular as we have only 1 process to run
2+
3+
from apscheduler.schedulers.blocking import BlockingScheduler
4+
5+
from caller import search
6+
7+
8+
sched = BlockingScheduler()
9+
10+
# Schedule job_function to be called every two hours
11+
sched.add_job(search, 'interval',hours=1) # for testing instead add hours =1
12+
13+
sched.start()

Base Converter Number system

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
def base_check(xnumber, xbase):
2+
for char in xnumber[len(xnumber ) -1]:
3+
if int(char) >= int(xbase):
4+
return False
5+
return True
6+
7+
def convert_from_10(xnumber, xbase, arr, ybase):
8+
if int(xbase) == 2 or int(xbase) == 4 or int(xbase) == 6 or int(xbase) == 8:
9+
10+
if xnumber == 0:
11+
return arr
12+
else:
13+
quotient = int(xnumber) // int(xbase)
14+
remainder = int(xnumber) % int(xbase)
15+
arr.append(remainder)
16+
dividend = quotient
17+
convert_from_10(dividend, xbase, arr, base)
18+
elif int(xbase) == 16:
19+
if int(xnumber) == 0:
20+
return arr
21+
else:
22+
quotient = int(xnumber) // int(xbase)
23+
remainder = int(xnumber) % int(xbase)
24+
if remainder > 9:
25+
if remainder == 10: remainder = 'A'
26+
if remainder == 11: remainder = 'B'
27+
if remainder == 12: remainder = 'C'
28+
if remainder == 13: remainder = 'D'
29+
if remainder == 14: remainder = 'E'
30+
if remainder == 15: remainder = 'F'
31+
arr.append(remainder)
32+
dividend = quotient
33+
convert_from_10(dividend, xbase, arr, ybase)
34+
def convert_to_10(xnumber, xbase, arr, ybase):
35+
if int(xbase) == 10:
36+
for char in xnumber:
37+
arr.append(char)
38+
flipped = arr[::-1]
39+
ans = 0
40+
j = 0
41+
42+
for i in flipped:
43+
ans = ans + (int(i) * (int(ybase) ** j))
44+
j = j + 1
45+
return ans
46+
arrayfrom = []
47+
arrayto = []
48+
is_base_possible = False
49+
number = input("Enter the number you would like to convert: ")
50+
51+
while not is_base_possible:
52+
base = input("What is the base of this number? ")
53+
is_base_possible = base_check(number, base)
54+
if not is_base_possible:
55+
print(f"The number {number} is not a base {base} number")
56+
base = input
57+
else:
58+
break
59+
dBase = input("What is the base you would like to convert to? ")
60+
if int(base) == 10:
61+
convert_from_10(number, dBase, arrayfrom, base)
62+
answer = arrayfrom[::-1] # reverses the array
63+
print(f"In base {dBase} this number is: ")
64+
print(*answer, sep='')
65+
elif int(dBase) == 10:
66+
answer = convert_to_10(number, dBase, arrayto, base)
67+
print(f"In base {dBase} this number is: {answer} ")
68+
else:
69+
number = convert_to_10(number, 10, arrayto, base)
70+
convert_from_10(number, dBase, arrayfrom, base)
71+
answer = arrayfrom[::-1]
72+
print(f"In base {dBase} this number is: ")
73+
print(*answer, sep='')
74+
© 2020 GitHub, Inc.

0 commit comments

Comments
 (0)