0% found this document useful (0 votes)
6 views3 pages

Python Functions Assessment Answers

The document contains a series of Python function definitions that perform various tasks, including temperature conversion, summation of numbers, factorial calculation, counting positive numbers, determining odd or even counts, averaging test scores, doubling numbers, counting characters in a string, translating text by removing vowels, and summing the digits of a number. Each function is designed to take specific inputs and return the corresponding output based on the defined logic. There is also a bonus question that involves calculating the digit sum until a single-digit result is obtained.

Uploaded by

eva acton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Python Functions Assessment Answers

The document contains a series of Python function definitions that perform various tasks, including temperature conversion, summation of numbers, factorial calculation, counting positive numbers, determining odd or even counts, averaging test scores, doubling numbers, counting characters in a string, translating text by removing vowels, and summing the digits of a number. Each function is designed to take specific inputs and return the corresponding output based on the defined logic. There is also a bonus question that involves calculating the digit sum until a single-digit result is obtained.

Uploaded by

eva acton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#Question 1

def FtoC(F):
return (F-32)/1.8

#Question 2
def sum_between(start,end):
total = 0
for number in range(start,end+1):
total = total + number
return total

#Question 3
def factorial(n):
total = 1
for i in range(1,n+1):
total = total*i
return total

#Question 4
def positivity(numbers):

#missing line of code here


total = 0

for num in numbers:


if num>0:
total=total+1
return total

#Question 5
def odd_or_even(numbers):
odds = 0
evens = 0
for num in numbers:
if num%2==0:
evens+=1
else:
odds+=1
return [odds,evens]
#Question 6
def ave_test_score(scores):
total = 0
for score in scores:
total+=score
return total/len(scores)

#Question 7
def doubler(numbers):
new_numbers=[]
for num in numbers:
double_num = 2*num
new_numbers.append(double_num)
return new_numbers

#Question 8
def character_counter(text,char):
text = text.upper()
char = char.upper()
return text.count(char)

#Question 9
def the_Kiwi_translator(text):
new_text = ""
for char in text:
if char.upper() not in "AEIOU":
new_text+=char
return new_text

#Question 10
def digits_sum(number):
number = str(number)
total = 0
for n in number:
total+=int(n)
return total

#Bonus Question
def digit_sum(number):
number = str(number)

final_total = 10

while final_total>=10:
total = 0
for n in number:
total+=int(n)
number = str(total)
final_total = total
return final_total

You might also like