Skip to content
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
17 changes: 17 additions & 0 deletions alphabetical_order
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 3-alphabetical_order.py
# Write a function that takes an input form user which separates the words
# hyphen icon(-) and sort the words alphabetical order and then adds hyphen
# icon (-) between them and gives the output of it.
# Input >>> green-red-yellow-black-white
# Output >>> black-green-red-white-yellow

def alphabetical_order():
words=input("Enter some words separetely: ")
words_list=words.lower().split(" ")
words_list_alphabetical=sorted(words_list)
words_in_order=""
for i in words_list_alphabetical:
words_in_order+=i+"-"
print(words_in_order[:-1])

alphabetical_order()
19 changes: 19 additions & 0 deletions equal_reverse
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 5-equal_reverse.py
# Write a function that controls the given inputs wheter they are equal with their reverse writing or not.
# Input >>> madam, tacocat, utrecht
# Output >>> True, True, False

def equal_reverse ():
word=input("Type some words separately: ")
word_list=list(word.split(" "))
result_list=[]
for i in word_list:
if len(i)%2==0 and i[:int(len(i)/2)][::-1]==i[int(len(i)/2):]:
print("True")
elif len(i)%2==0 and i[:int(len(i)/2)][::-1]!=i[int(len(i)/2):]:
print("False")
elif len(i)%2==1 and i[:int(len(i)//2)][::-1]==i[int(len(i)//2)+1:]:
print("True")
elif len(i)%2==1 and i[:int(len(i)//2)][::-1]!=i[int(len(i)//2)+1:]:
print("False")
equal_reverse()
10 changes: 10 additions & 0 deletions hackerrank Capitalize
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# hackerrank Capitalize


def solve(s):

s=s[0].upper()+s[1:]
for i in range(len(s)):
if s[i]==" ":
s=s[:i+1]+s[i+1].upper()+s[i+2:]
return s
14 changes: 14 additions & 0 deletions hackerrank Find Digits
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# hackerrank Find Digits Complete the findDigits function below.

def findDigits(n):
t=str(n)
k=0
for i in range(len(t)):
if int(t[i])==0:
continue
elif n%int(t[i])==0:
k+=1
else:
pass
# print(k)
return k
21 changes: 21 additions & 0 deletions perfect_number
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 1-perfect_number.py
# 1-The smallest perfect number is 6, which is the sum of 1, 2, and 3.
# Other perfect numbers are 28(1+2+4+7+14=28), 496 and 8128. between 1 and 1000.
# numbers between 1 and 1000 and find the sum of the prime numbers using with reduce and filter functions.

def perfect_numbers():

a=1000
b=[]
for i in range(1,a+1):
b.append(i)

for i in b:
t=0
for k in range(1,i):
if i%k==0:
t+=k
if t==i:
print(t)

perfect_numbers()
23 changes: 23 additions & 0 deletions reading_number
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 2.reading_number 28---------------->Twenty Eight

tens=["twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"]
ones=["one","two","three","four","five","six","seven","eight","nine"]
teen=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"]

def number_written():

a=int(input("Enter a two digit number "))
a1=a%10
a2=a//10

if 9<a<20:
print("{}---------------->{}".format(a,teen[a1]))
elif 19<a<100:
if a1==0:
print("{}---------------->{}".format(a,tens[a2-2]))
else:
print("{}---------------->{}".format(a,tens[a2-2]+" "+ones[a1-1]))
else:
print("Please enter a correct number!")

number_written()
14 changes: 14 additions & 0 deletions unique_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 4-unique_list.py
# Write a function that filters unique(unrepeated) all elements of a given list.
# Function call: unique_list([1,2,3,3,3,3,4,5,5])
# Output : [1, 2, 3, 4, 5]

def unique_list():
numbers=input("Enter some numbers separetely: ")
number_list=set(numbers.split(" "))
t=[]
for i in number_list:
t.append(int(i))
print(t)

unique_list()