def vol(rad):
pi = 3.14
volume = (4/3)* pi *(rad**3)
round(volume)
Run to view results
# Check
vol(2)
Run to view results
def ran_check(num,low,high):
if num in range (low, high + 1):
print('{} is in the range between {} and {}' .format(num,low,high))
else:
print('The number is outside the range {} and {}' .format(low,high))
Run to view results
# Check
ran_check(5,2,7)
Run to view results
def ran_bool(num,low,high):
return num in range (low,high+1)
pass
Run to view results
ran_bool(3,1,10)
Run to view results
def up_low(s):
d= {"upper":0, "lower":0}
for c in s:
if c.isupper():
d["upper"]+=1
elif c.islower():
d["lower"]+=1
else:
pass
print("original string :", s)
print("No. of Uppser caharaters: ", d["upper"])
print("No. of Lower caharaters: ", d["lower"])
Run to view results
s = 'Hello Mr. Rogers, how are you this fine Tuesday?'
up_low(s)
Run to view results
def unique_list(lst):
x = []
for a in set(lst):
x.append(a)
return x
pass
Run to view results
unique_list([1,1,1,1,2,2,3,3,3,3,4,5])
Run to view results
def multiply(numbers):
num = 1
for x in numbers:
num *= x
return num
pass
Run to view results
multiply([1,2,3,-4])
Run to view results
def palindrome(s):
s == s.replace(' ', '')
return s== s[::-1]
pass
Run to view results
print(palindrome('helleh'))
print(palindrome('helleh racknarok'))
Run to view results
import string
def ispangram(str1, alphabet=string.ascii_lowercase):
alphaset = set(alphabet)
return alphaset <= set(str1.lower())
Run to view results
ispangram("The quick brown fox jumps over the lazy dog")
Run to view results
string.ascii_lowercase
Run to view results