Programming in Python, End Term
Consider the following functions: def p(n): if n < 10: return 1 return 1 + p(n // 10) def q(n): if n < 10: return n return n % 10 + q(n // 10) def r(n): if n <= 1: return 1 return n * r(n - 1) Which of the following function calls returns the number of digits in 50!, where n! is the factorial of n?
Consider the following functions: def p(n): if n < 10: return 1 return 1 + p(n // 10) def q(n): if n < 10: return n return n % 10 + q(n // 10) def r(n): if n <= 1: return 1 return n * r(n - 1) Which of the following function calls returns the number of digits in 50!, where n! is the factorial of n? Consider the following code snippet that writes student details to a CSV file named "employees.csv": def save_data(data): f = open('employees.csv', 'w') f.write('Name,Salary\n') for i in range(len(data)): emp, sal = data[i] row = f'{emp},{sal}' if i != len(data) - 1: row = row + '\n' f.write(row) f.close() data = [ ('Alice', 75000), ('Bob', 64000), ('Charlie', 82000), ('Diana', 71000), ('Eve', 69000) ] If the save_data(data) function is called with the list data as shown above, what will be the contents of the file "employees.csv"? What will be the output of the following Python code? string1 = 'database' string2 = 'baseball' L = [] for i in range(len(string1)): for j in range(len(string2)): if string1[i] == string2[j]: L.append(string1[i]) break else: continue print(L)