CS Summer Assignment
CS Summer Assignment
Assignment 🌟
1. Definitions (15)
1. 1. Algorithm – A step-by-step procedure to solve a problem.
2. 2. Flowchart – A diagrammatic way to represent an algorithm.
3. 3. Variable – A named memory location used to store data.
4. 4. Data Type – Type of data (like int, float, str) a variable can hold.
5. 5. Operator – Symbols used to perform operations (e.g., +, -, *, /).
6. 6. Conditional Statement – Used to perform actions based on conditions (if, else).
7. 7. Loop – A control structure that repeats code (for, while).
8. 8. Function – A block of reusable code that performs a specific task.
9. 9. Parameter – A variable in a function definition.
10. 10. Argument – A value passed to a function when called.
11. 11. Syntax Error – Error in the structure of the program.
12. 12. Runtime Error – Error that occurs during program execution.
13. 13. Logical Error – Error in logic; program runs but gives wrong output.
14. 14. IDE – Integrated Development Environment for writing code (e.g., IDLE).
15. 15. Interpreter – Software that runs code line by line (like Python).
# 6. Factorial of a number
n=5
fact = 1
for i in range(1, n+1):
fact *= i
print("Factorial:", fact)
# 9. Sum of digits
num = 123
sum_digits = 0
while num > 0:
sum_digits += num % 10
num //= 10
print("Sum of digits:", sum_digits)