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

CS Summer Assignment

The document contains a computer science summer assignment with definitions of key programming concepts, Python programs demonstrating various functionalities, output-based questions with expected results, and error-finding questions with corrections. It covers algorithms, data types, and common programming errors, along with practical Python examples like printing, loops, and conditionals. The assignment is structured to enhance understanding of programming fundamentals and problem-solving skills.

Uploaded by

sonu25082008
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)
2 views3 pages

CS Summer Assignment

The document contains a computer science summer assignment with definitions of key programming concepts, Python programs demonstrating various functionalities, output-based questions with expected results, and error-finding questions with corrections. It covers algorithms, data types, and common programming errors, along with practical Python examples like printing, loops, and conditionals. The assignment is structured to enhance understanding of programming fundamentals and problem-solving skills.

Uploaded by

sonu25082008
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

🌟 Computer Science Summer

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).

2. Python Programs (10)


# 1. Print Hello World
print("Hello, World!")

# 2. Add two numbers


a=5
b=3
print("Sum:", a + b)

# 3. Check even or odd


num = 7
if num % 2 == 0:
print("Even")
else:
print("Odd")

# 4. Find largest of three numbers


a, b, c = 10, 5, 8
print("Largest:", max(a, b, c))
# 5. Multiplication table of a number
n=4
for i in range(1, 11):
print(n, "x", i, "=", n*i)

# 6. Factorial of a number
n=5
fact = 1
for i in range(1, n+1):
fact *= i
print("Factorial:", fact)

# 7. Check prime number


n=7
is_prime = True
for i in range(2, int(n/2)+1):
if n % i == 0:
is_prime = False
break
print("Prime" if is_prime else "Not Prime")

# 8. Fibonacci series up to 10 terms


a, b = 0, 1
for _ in range(10):
print(a, end=" ")
a, b = b, a + b

# 9. Sum of digits
num = 123
sum_digits = 0
while num > 0:
sum_digits += num % 10
num //= 10
print("Sum of digits:", sum_digits)

# 10. Reverse a string


s = "Python"
print("Reversed:", s[::-1])

3. Output-Based Questions (10)


16. Q1: a = 10
b=3
print(a % b) => Output: 1
17. Q2: x = "Hello"
y = "World"
print(x + y) => Output: HelloWorld
18. Q3: print(2 ** 3 ** 1) => Output: 8
19. Q4: a = 4
a += 2
print(a) => Output: 6
20. Q5: print(len("Python")) => Output: 6
21. Q6: print("5" + "6") => Output: 56
22. Q7: print(bool(0), bool(1)) => Output: False True
23. Q8: print(10 // 3) => Output: 3
24. Q9: x = [1, 2, 3]
print(x[1]) => Output: 2
25. Q10: print("Python"[::-1]) => Output: nohtyP

4. Error-Finding Questions (5)


26. Q1: if a == 5
print("Yes")
Error: Missing colon
Fix: if a == 5:
27. Q2: print("Hello)
Error: Unclosed string
Fix: print("Hello")
28. Q3: for i in range(5)
print(i)
Error: Missing colon
Fix: for i in range(5):
29. Q4: def greet
print("Hi")
Error: Missing parentheses
Fix: def greet():
30. Q5: num = int("abc")
Error: ValueError
Fix: Use try-except or pass a valid number string

You might also like