Skip to content

Commit d13cfcb

Browse files
committed
python task
1 parent 8a00494 commit d13cfcb

10 files changed

+110
-0
lines changed

34 count string.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#---- 34 count vowels / consonants ----
2+
print('To count vowels / consonants.')
3+
string = input('Enter string: ')
4+
string = string.lower()
5+
vowelcount = 0
6+
consonantcount = 0
7+
for s in string :
8+
if s == 'a' or s == 'e' or s == 'i' or s == 'o' or s == 'u' :
9+
vowelcount += 1
10+
else:
11+
consonantcount +=1
12+
print('number of vowels : ',vowelcount,'\nnumber of consonants : ',consonantcount)

35 note distribution.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#---- to find the number of notes (Sample of notes: 10, 20, 50, 100, 500, and 1000 ) against an given amount ----
2+
print('Find the number of notes in your given amount')
3+
amount = int(input('Enter the amount of money : '))
4+
amu1000 = amount // 1000
5+
amu500 = (amount % 1000 ) // 500
6+
amu100 = ((amount % 1000) % 500) // 100
7+
amu50 = (((amount % 1000) % 500) % 100 ) // 50
8+
amu20 = ((((amount % 1000) % 500) % 100 ) % 50) // 20
9+
amu10 = (((((amount % 1000) % 500) % 100 ) % 50) % 20) // 10
10+
amuleft = (((((amount % 1000) % 500) % 100 ) % 50) % 20) % 10
11+
print('Amount : ',amount)
12+
print('notes of 1000 : ',amu1000)
13+
print('notes of 500 : ',amu500)
14+
print('notes of 100 : ',amu100)
15+
print('notes of 50 : ',amu50)
16+
print('notes of 20 : ',amu20)
17+
print('notes of 10 : ',amu10)
18+
print('remaining amu : ',amuleft)

36 palindrome or not.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#---- to check whether given input is palindrome or not ----
2+
print('check whether your input is palindrome or not')
3+
string = input('provide input : ')
4+
string1 = string[::-1]
5+
if string == string1 :
6+
print('palindrome')
7+
else:
8+
print('not palindrome')

37 number palindrome.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#---- program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure ----
2+
def number():
3+
num_inp = input('Enter digits : ')
4+
num_inp_rev = num_inp[::-1]
5+
num_total_inp = int(num_inp) + int(num_inp_rev)
6+
num_total_inp = str(num_total_inp)
7+
num_totalrev = num_total_inp[::-1]
8+
while True :
9+
if num_total_inp != num_totalrev :
10+
print('The final sum of' , num_inp , 'and' , num_inp_rev ,'is' , num_total_inp ,'\nIts reverse is' , num_totalrev , 'and its not a palindrome.\ninput again')
11+
number()
12+
break
13+
else:
14+
print('The final sum of' , num_inp , 'and' , num_inp_rev ,'is' , num_total_inp ,'\nIts reverse is' , num_totalrev , 'and its a palindrome.')
15+
break
16+
number()
17+
18+
19+
20+

38 Fibonacci series.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#---- program to get the Fibonacci series between 0 to 50 ----
2+
print('The Fibonacci series')
3+
num = int(input('Enter the number of digits that you want in the series : '))
4+
first = 0
5+
second = 1
6+
nextnum = 0
7+
print(first , second , end=' ')
8+
for num in range(2, num) :
9+
nextnum = first + second
10+
print(nextnum , end = ' ')
11+
first = second
12+
second = nextnum
13+

39 multiplication table.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#---- program to create the multiplication table (from 1 to 10) of a number ---
2+
print('Multiplicaion table (1 to 10)')
3+
num = int(input('Enter a number to see its table : '))
4+
for i in range(1, 11) :
5+
print(num , 'x' , i ,'=' , num * i )

40 count lettersdigits.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#---- program that accepts a string and calculate the number of digits and letters ----
2+
print('To count letters and digits in a given string')
3+
string = input('Enter string : ')
4+
digits = 0
5+
letters = 0
6+
for s in string :
7+
if s.isdigit() :
8+
digits += 1
9+
elif s.isalpha() :
10+
letters += 1
11+
print('Letters : ',letters ,'\nDigits : ',digits)

41 pattern1.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#---- pattern with nested loop ----
2+
for row in range(1, 6):
3+
for col in range(1, row+1):
4+
print('*', end ='')
5+
print("")
6+
for row in range(4, 0, -1):
7+
for col in range(1, row + 1):
8+
print('*', end ='')
9+
print("")

42 pattern2.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#---- pattern with nested loop ----
2+
for row in range(1, 6):
3+
for col in range(1, row+1):
4+
print(col, end ='')
5+
print("")
6+
for row in range(4, 0, -1):
7+
for col in range(1, row + 1):
8+
print(col, end ='')
9+
print("")

43 pattern3.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#---- Pattern with nested loop ----
2+
for row in range(10) :
3+
for col in range (row):
4+
print(row , end="")
5+
print("")

0 commit comments

Comments
 (0)