def vol(rad):
return (4/3)*(3.14)*(rad**3)
Run to view results
# Check
vol(2)
Run to view results
def ran_check(num,low,high):
if high >= num >= low:
return "within range"
else:
return "out of range"
Run to view results
# Check
ran_check(5,2,7)
Run to view results
def ran_bool(num,low,high):
return high >= num >= low
Run to view results
ran_bool(3,1,10)
Run to view results
import collections
def up_low(s):
c = collections.Counter("upper" if x.isupper() else "lower" if x.islower() else "" for x in s)
print(f'Original String : {s}')
print(f'No. of Upper case characters : {c["lower"]}')
print(f'No. of Lower case Characters : {c["upper"]}')
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):
return list(set(lst))
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):
product = 1
for num in numbers:
product *= num
return product
Run to view results
multiply([1,2,3,-4])
Run to view results
import numpy
def multiply(numbers):
return numpy.prod(numbers)
multiply([1,2,3,-4])
Run to view results
def palindrome(s):
return (s == s[::-1])
Run to view results
palindrome('helleh')
Run to view results
import string
def ispangram(str1, alphabet=string.ascii_lowercase):
my_list=sorted(list(set(str1.lower().replace(" ",""))))
return "".join(my_list) == alphabet
Run to view results
import string
def ispangram(str1, alphabet=string.ascii_lowercase):
return set(alphabet) <= 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