Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added codes #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Task2/DataStructures/Python/avg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n = int(input("Enter number of elements : "))
a = []
for i in range(0,n):
elem = int(input("Enter a number : "))
a.append(elem)
avg = sum(a)/n
print("The average is :", round(avg,2))
10 changes: 10 additions & 0 deletions Task2/DataStructures/Python/calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
text = input("Enter the string: ").lower()
vowels = sum(1 for a in text if a in 'aeiou')
consonants = sum(1 for a in text if a.isalpha() and a not in 'aeiou')
digits = sum(1 for a in text if a.isdigit())
spaces = sum(1 for a in text if a.isspace())

print("Vowels:", vowels)
print("Consonants:", consonants)
print("Digits:", digits)
print("White spaces:", spaces)
4 changes: 4 additions & 0 deletions Task2/DataStructures/Python/exchange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a = int(input("Enter value of a : "))
b = int(input("Enter value of b : "))
a,b = b,a
print("Exchanged values are : a is", a, "b is",b)
12 changes: 12 additions & 0 deletions Task2/DataStructures/Python/fibanocci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nterms = int(input("How many terms? "))
n1, n2 = 0, 1

if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto", nterms ,":")
else:
print("Fibonacci sequence:")
for _ in range(nterms):
print(n1)
n1, n2 = n2, n1 + n2
5 changes: 5 additions & 0 deletions Task2/DataStructures/Python/palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a = input("Enter number/string to check if its palindrome : ")
if (a==a[::-1]):
print("The entered input is a palindrome!")
else :
print("The entered input is not a palindrome")
13 changes: 13 additions & 0 deletions Task2/DataStructures/Python/sort_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a = []
c=[]
n1 = int(input("Enter number of elements: "))
for i in range(1,n1+1):
b=int(input("Enter Element"))
a.append(b)
n2 = int(input("Enter number of elements: "))
for i in range(1,n2+1):
d=int(input("Enter Element"))
c.append(d)
new=a+c
new.sort()
print("Sorted list is: ", new)