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 elapsed_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Measure The Elapsed Time
#importing time module
import time
#Records the current time
start=time.time()
'''
The loop runs from 0 to 9 taking some time
in each iteration.
'''
for i in range(0,10):
print(i)
#The execution is paused for 5 seconds
time.sleep(5)
#records the ending time
end=time.time()
#Elapsed time= Start Time-End Time
print(f'Elapsed Time :{end-start:.3f} seconds')
13 changes: 13 additions & 0 deletions n_digit_random_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#A Function That Takes A Number 'n' And Then Returns A Randomly Generated Number Having 'n' Digits
#importing Random Module
import random

def gennum(n):
lbound=10**(n-1) #lower bound
ubound=(10**n)-1 #upper bound
return random.randint(lbound,ubound)

#Taking Input From User
n=int(input("Enter A Number:"))
rnum=gennum(n)
print("Random Number:", rnum)
20 changes: 20 additions & 0 deletions type_enter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#Prompts The User To Type Some Sentence(s) Followd By 'enter'
s=input("Enter Few Sentences:")
l=len(s)
c=0 #Count For Whitespaces
alc=0 #Count For Alphanumeric Characters
for ch in s :
if ch.isspace():
c+=1
elif ch.isalnum():
alc+=1
'''
Percentage Calculation For Occurence Of
Alphanumeric Characters In The Sentence
'''
alnp=alc/l*100
print("Original Sentence:")
print(s)
print("Number Of Words:",(c+1))
print("Number Of Character:",l)
print("Alphanumeric Percentage:",alnp,"%")