Skip to content

Commit

Permalink
7 files added
Browse files Browse the repository at this point in the history
  • Loading branch information
26rudra committed Jul 20, 2022
1 parent b733595 commit ee5ee43
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 0 deletions.
Binary file added __pycache__/twentyfunction.cpython-310.pyc
Binary file not shown.
9 changes: 9 additions & 0 deletions twenty(five).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def sum_of_ascii(input_string):
sum = 0
for i in input_string:
var = ord(i)
sum = sum + var
return sum
total = sum_of_ascii('rudraksh')
print(total)

8 changes: 8 additions & 0 deletions twenty(four).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def string(my_string):
if my_string.isupper():
return True
elif my_string.islower():
return False
print(string('RUDRAKSH'))


5 changes: 5 additions & 0 deletions twenty(one).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def table(n):
for i in range(1,11):
print(n*i)
table(6)
#to import any function we can use from file name functions import
8 changes: 8 additions & 0 deletions twenty(seven).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def alpha_freq(my_string):
flag = 0
for i in range(len(my_string)-1):
if ord(my_string[i]) + 1 == ord(my_string[i+1]):
flag += 1
return flag
my_value = alpha_freq('abcade')
print(my_value)
13 changes: 13 additions & 0 deletions twenty(six).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#map function: map(ord, lst/str/[])
# def sum_of_ascii(input_string):
# return sum(map(ord, input_string))

# map(len, [['shiv'], ['ank']]) #1
def generate_password(username , password):
username = username[:4]
password = password[-4:]

value = username + password
return value
last_pass = generate_password('rudraksh' , '12345678')
print(last_pass)
4 changes: 4 additions & 0 deletions twenty(three).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def mylist():
lst=[1,2,3]
return lst
print(mylist())
2 changes: 2 additions & 0 deletions twenty(two).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from twentyfunction import factorial
print(factorial(6))
16 changes: 16 additions & 0 deletions twentyfunction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# def greet():
# print("hello world")
# return 'hi mars!'
# var = greet()
# print(var)

def factorial(n):
fact = 1
for i in range(1, n+1):
fact = fact * i
return fact
fact_of_5 = factorial(5)
fact_of_10 = factorial(10)
print(fact_of_5)
print(fact_of_10)

0 comments on commit ee5ee43

Please sign in to comment.