Skip to content

Instantly share code, notes, and snippets.

View RaMSFT's full-sized avatar

RaMS Nelluri RaMSFT

View GitHub Profile
def i_hate_space(chr, stmt):
result = stmt.replace(' ',chr)
return result
print(i_hate_space("H", "Hello welcome to my Blog"))
print(i_hate_space("R", "python is fun"))
print(i_hate_space("#", "hello world!"))
def evaluate_equation(eq):
result = eval(eq)
return result
print(evaluate_equation("1+2"))
print(evaluate_equation("6/(9-7)"))
print(evaluate_equation("3+2-4"))
def long_burp(num):
burp_str = 'Burp'
long_r = 'r' * num
long_burp_str = burp_str.replace('r', long_r)
return long_burp_str
def on_off_switch(switches):
# ** operator in Python works as power
posibilities = 2 ** switches
return posibilities
print(on_off_switch(1))
print(on_off_switch(3))
print(on_off_switch(10))
def check_number_in_list(lst, num):
if num in lst:
result = f"{num} exist in the list"
else:
result = f"{num} doesn't exist in the list"
return result
def range_of_num(start, end):
if start < end:
result = list(range(start + 1, end))
else:
result = "Wrong input..!! Range Start number must be Less than end number"
return result
def num_to_dashes(num):
if num < 1 or num > 60:
return "Wrong input"
else:
return "-" * num
print(num_to_dashes(1))
print(num_to_dashes(5))
print(num_to_dashes(3))
def strin_odd_or_even(str):
str_length = len(str)
if str_length % 2 == 0:
return True
else:
return False
def concat_last_first_name(first, last):
full_name = f"{last}, {first}"
return full_name
print(concat_last_first_name("First", "Last"))
print(concat_last_first_name("John", "Nelluri"))
def is_string_empty_len(str):
str_len = len(str)
if str_len == 0:
return True
else:
return False
print(is_string_empty_len("a"))