## Python Homework Solution on Function Call

• 27th Jan, 2022
• 16:09 PM
```def one_plus_one():
one = 1
output = one + one
return output

def well_um(sentence):
word_num = 0
output = ''
choice = 0
choices = ['uh','well','I mean','um']
sentence_list = sentence.split(' ')

length = len(sentence_list)

for word in sentence_list:

output = output + word
if (choice > 3):
choice = 0
if (len(word) > 5):
if word_num != length - 1:
output = output + ', ' + choices[choice] + ', '

choice += 1
else:
output += ' '

word_num += 1

print(output)

def question_1():
well_um('I am taking my final exam today and I am a little nervous.')

def two_num_average(num1,num2):
return((num1+num2)/2)

output = []

length = len(list_of_numbers)

for i in range(length):
if i != length - 1:
output.append(list_of_numbers[i])
last_number = list_of_numbers[i]
number = list_of_numbers[i+1]
output.append(two_num_average(last_number,number))
else:
output.append(list_of_numbers[i])

return(output)
def question_2():

def classify_spaces(infile):
before_count = {}
after_count = {}
previous_character = ''
after_set = 0

with open(infile,'r') as instream:
if character == ' ':
after_set = 1
if previous_character in before_count.keys():
before_count[previous_character] += 1
else:
before_count[previous_character] = 1
else:
if after_set == 1:
if character in after_count.keys():
after_count[character] += 1
else:
after_count[character] = 1

after_set = 0

previous_character = character

after_keys = list(after_count.keys())
before_keys = list(before_count.keys())

after_keys.sort()
before_keys.sort()

print('Characters Before Spaces\tFrequency')
for char in before_keys:
print(char+'\t'+str(before_count[char]))

print('Characters After Spaces\tFrequency')
for char in after_keys:
print(char+'\t'+str(after_count[char]))```