Skip to content

Commit d243e6e

Browse files
committed
Initial commit
0 parents commit d243e6e

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

99BottlesOfBeer.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Authour: azmathias Stuperuser Ltd
2+
# Purpose: A program printing out every line to the song "99 bottles of beer on the wall"
3+
# Notes: Besides the phrase "take one down," you may not type in any numbers/names of numbers directly into your song lyrics
4+
# Follow grammatic rules
5+
6+
7+
def sing(n):
8+
if (n == 1):
9+
objects = 'bottle'
10+
objectsMinusOne = 'bottles'
11+
elif (n == 2):
12+
objects = 'bottles'
13+
objectsMinusOne = 'bottle'
14+
else:
15+
objects = 'bottles'
16+
objectsMinusOne = 'bottles'
17+
18+
19+
if (n > 0):
20+
print(str(n) + " " + objects + " of beer on the wall, " + str(n) + " " + objects + " of beer.")
21+
print("Take one down and pass it around, " + str(n-1) + " " + objectsMinusOne + " of beer on the wall.")
22+
print(" ")
23+
elif (n == 0):
24+
print("No more bottles of beer on the wall, no more bottles of beer.")
25+
print("Go to the store and buy some more, 99 bottles of beer on the wall.")
26+
else:
27+
print("Error: Wheres the booze?")
28+
bottles = 99
29+
30+
while bottles >= 0:
31+
sing(bottles)
32+
bottles -= 1

ArmstrongNumber.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Authour: azmathias Stuperuser Ltd
2+
# Purpose: Define a function that allows the user to check whether a given number is armstrong number or not.
3+
# Number x, no of digits = n, if the sum of each digit raised to the power of n is equal to x, the number is an armstrong number (also called narcisstic numbers)
4+
# Notes: All single digit numbers are armstrong numbers
5+
# TODO: Add more user input so users can check a number more than once, add error handling
6+
7+
print("Armstrong Number Checker \n")
8+
num = int(input("Please enter a number"))
9+
10+
# calculate the length of the input number
11+
pownum = len(str(num))
12+
13+
sum = 0
14+
15+
resnum = num
16+
while resnum > 0:
17+
digit = resnum % 10
18+
sum += digit ** pownum
19+
resnum //= 10
20+
21+
if num == sum:
22+
print(num,"is an Armstrong number")
23+
else:
24+
print(num,"is not an Armstrong number")
25+
26+

README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)