Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer Science Final Exam: Python Programming Exercises, Exams of Computer Science

A set of python programming exercises designed for a final exam in computer science. The exercises cover fundamental concepts such as recursion and loops, focusing on practical application of these techniques. Students are challenged to write python functions that perform specific tasks, demonstrating their understanding of core programming principles.

Typology: Exams

2024/2025

Available from 03/05/2025

passlist-passlist
passlist-passlist 🇺🇸

5

(3)

2.1K documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science Final Exam 2025
pf3
pf4

Partial preview of the text

Download Computer Science Final Exam: Python Programming Exercises and more Exams Computer Science in PDF only on Docsity!

  • Computer Science Final Exam
1, Write a Python function called sum_digits that accepts an integer n and returns the sum of its digits. You must implement the solution using recur sion: def sum_digits (n): ifn < 10: return n alse: return n % 10 + sum_digits(n // 10) 2, Write a Python function called reverse_list that accepts a list Ist and returns anew list with the clements in reverse order, You must implement the solution using recursion: def reverse_list (Ist): if len (Ist) == return [] alse: return [IstI-1]] + reverse_list (Ist l:-11) 3. Coding Loops Question: Write a Python function called compute_sum that accepts a list of integers Ist and returns the sum of all the clements in the list. You must implement the solution using a loop: del compute_sum (Ist): tatal = 0 for num in Ist: total += num return total