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 num in range(low,high +1):
print(f"{num} is in between {low} and {high}")
else:
print(f" {num} is not in between {low} and {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)
Run to view results
ran_bool(3,1,10)
Run to view results
s = 'Hello Mr. Rogers, how are you this fine Tuesday?'
Run to view results
def up_low(s):
if isinstance(s, str):
upper_count = 0
lower_count = 0
for i in s:
if i.isupper():
upper_count += 1
elif i.islower():
lower_count += 1
else:
pass
print(f"{s}")
print(f"Upper Case Count: {upper_count}")
print(f"Lower Case Count: {lower_count}")
else:
print("You did not enter a string")
Run to view results
s = [0,7,5]
up_low(s)
Run to view results
def unique_list(lst):
x = []
for i in lst:
if i not in x:
x.append(i)
return x
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):
x = 1
if isinstance(numbers, list):
for i in numbers:
x *= i
return x
else:
print(f"Your input is not a list")
Run to view results
multiply([1,2,3,-5])
Run to view results
def palindrome(s):
if isinstance(s,str):
s = s.replace(" ", "")
return s == s[::-1]
Run to view results
palindrome('hellea')
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