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 760d52a

Browse files
added 7 solutions
1 parent ca388ab commit 760d52a

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import math
2+
a = int(input("Enter the first number: "))
3+
b = int(input("Enter the second number: "))
4+
print("The GCD of", a, "and", b, "is:", math.gcd(a,b))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import math
2+
a = int(input("Enter the first number: "))
3+
b = int(input("Enter the second number: "))
4+
print("The LCM of", a, "and", b, "is:", (a/math.gcd(a,b))*b)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def countVowelsAndConsonants(string):
2+
vowels = set("aeiouAEIOU")
3+
consonants = set("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ")
4+
vowel_count, consonant_count = 0, 0
5+
for char in string:
6+
if char in vowels:
7+
vowel_count += 1
8+
elif char in consonants:
9+
consonant_count += 1
10+
return {vowel_count, consonant_count}
11+
12+
string = str(input("Enter the string: "))
13+
vowels, consonants = countVowelsAndConsonants(string)
14+
print(f"Vowels: {vowels}, Consonants: {consonants}")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
string = str(input("Enter the string: "))
2+
print("Reversed String: ", string[::-1])

‎Problem Solving in Python/01_Basic Problems/Solutions/solution14.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def factorial(number):
2+
if number == 0 or number == 1:
3+
return 1
4+
return number * factorial(number-1)
5+
6+
number = int(input("Enter the number: "))
7+
print("Factorial of", number, "is: ", factorial(number))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
number = int(input("Enter the number: "))
2+
strNumber = str(number)
3+
sum_of_digits = 0
4+
for i in strNumber:
5+
sum_of_digits += int(i)
6+
print("Sum of the digits: ", sum_of_digits)

0 commit comments

Comments
(0)

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