Skip to content

Commit efb7907

Browse files
Merge branch 'geekcomputers:master' into master
2 parents a7bf2fe + 4488fed commit efb7907

20 files changed

+67
-65
lines changed

Add two numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
sum = num1 + num2
88

99
# Display the sum
10-
print("The sum of"num1,'and'num2,'is',sum)
10+
print(f"The sum of {num1} and {num2} is {sum}")

Armstrong_number.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
def is_armstrong_number(number):
2-
total = 0
1+
"""
2+
In number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number),
3+
in a given number base b, is a number that is the total of its own digits each raised to the power of the number of digits.
4+
Source: https://en.wikipedia.org/wiki/Narcissistic_number
5+
NOTE:
6+
this scripts only works for number in base 10
7+
"""
38

4-
# find the sum of the cube of each digit
5-
temp = number
6-
while temp > 0:
7-
digit = temp % 10
8-
total += digit ** 3
9-
temp //= 10
9+
def is_armstrong_number(number:str):
10+
total:int = 0
11+
exp:int = len(number) #get the number of digits, this will determinate the exponent
12+
13+
digits:list[int] = []
14+
for digit in number: digits.append(int(digit)) #get the single digits
15+
for x in digits: total += x ** exp #get the power of each digit and sum it to the total
1016

11-
# return the result
12-
if number == total:
13-
return True
17+
# display the result
18+
if int(number) == total:
19+
print(number,"is an Armstrong number")
1420
else:
15-
return False
21+
print(number,"is not an Armstrong number")
1622

17-
number = int(input("Enter the number: "))
18-
if is_armstrong_number(number):
19-
print(number,"is an Armstrong number")
20-
else:
21-
print(number,"is not an Armstrong number")
23+
number = input("Enter the number : ")
24+
is_armstrong_number(number)

BruteForce.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
def findPassword(chars, function, show=50, format_="%s"):
55

66
password = None
7-
attempts = 00
8-
size = 01
7+
attempts = 0
8+
size = 1
99
stop = False
1010

1111
while not stop:

Colors/multicoloredline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
console = Console()
77

8-
console.rule(multiclored=true)
8+
console.rule(multiclored=True)

FIND FACTORIAL OF A NUMBER.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Python program to find the factorial of a number provided by the user.
22

33
def factorial(n):
4-
if n < 0:
5-
return("Oops!Factorial Not Possible")
6-
elif n = 0:
7-
return 1
8-
else:
9-
return n*factorial(n-1)
4+
if n < 0:
5+
return "Oops!Factorial Not Possible"
6+
elif n == 0:
7+
return 1
8+
else:
9+
return n*factorial(n-1)
1010

1111
n = int(input())
1212
print(factorial(n))
13-

FibonacciNumbersWithGenerators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def fibonacci_generator(n = None):
1414
f0, f1 = f1, fn
1515
n -= 1
1616

17-
for n_fibo in fibonacci(7):
17+
for n_fibo in fibonacci_generator(7):
1818
print(n_fibo)

Grocery calculator.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@
88

99
#Object = GroceryList
1010
#Methods = addToList, Total, Subtotal, returnList
11-
1211
class GroceryList(dict):
1312

14-
def __init__(self):
15-
self = {}
13+
def __init__(self):
14+
self = {}
1615

17-
def addToList(self, item, price):
18-
self.update({item:price})
16+
def addToList(self, item, price):
17+
18+
self.update({item:price})
1919

20-
def Total(self):
20+
def Total(self):
2121
total = 0
2222
for items in self:
2323
total += (self[items])*.07 + (self[items])
2424
return total
2525

26-
def Subtotal(self):
26+
def Subtotal(self):
2727
subtotal = 0
2828
for items in self:
2929
subtotal += self[items]
3030
return subtotal
3131

32-
def returnList(self):
32+
def returnList(self):
3333
return self
3434

3535
'''Test list should return:
@@ -44,12 +44,12 @@ def returnList(self):
4444
List1.addToList("kombucha", 3)
4545

4646

47-
print List1.Total()
48-
print List1.Subtotal()
49-
print List1.returnList()
47+
print(List1.Total())
48+
print(List1.Subtotal())
49+
print(List1.returnList())
5050

5151
#*****************************************************
52-
print
52+
print()
5353
#*****************************************************
5454

5555

@@ -59,6 +59,6 @@ def returnList(self):
5959
List2.addToList('wine', 25.36)
6060
List2.addToList('steak', 17.64)
6161

62-
print List2.Total()
63-
print List2.Subtotal()
64-
print List2.returnList()
62+
print(List2.Total())
63+
print(List2.Subtotal())
64+
print(List2.returnList())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
numpy==1.25.1
1+
numpy==1.25.2
22
opencv_python==4.8.0.74
33
mediapipe==0.10.2

Mad Libs Generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//Loop back to this point once code finishes
1+
#Loop back to this point once code finishes
22
loop = 1
33
while (loop < 10):
4-
// All the questions that the program asks the user
4+
# All the questions that the program asks the user
55
noun = input("Choose a noun: ")
66
p_noun = input("Choose a plural noun: ")
77
noun2 = input("Choose a noun: ")
88
place = input("Name a place: ")
99
adjective = input("Choose an adjective (Describing word): ")
1010
noun3 = input("Choose a noun: ")
11-
// Displays the story based on the users input
11+
# Displays the story based on the users input
1212
print ("------------------------------------------")
1313
print ("Be kind to your",noun,"- footed", p_noun)
1414
print ("For a duck may be somebody's", noun2,",")
@@ -18,5 +18,5 @@
1818
print ("You may think that is this the",noun3,",")
1919
print ("Well it is.")
2020
print ("------------------------------------------")
21-
// Loop back to "loop = 1"
21+
# Loop back to "loop = 1"
2222
loop = loop + 1

PongPong_Game/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyglet==2.0.8
1+
pyglet==2.0.9

0 commit comments

Comments
 (0)