Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Computer science practice question paper with answers

Rating
-
Sold
-
Pages
4
Uploaded on
10-05-2025
Written in
2024/2025

Computer science practice question paper

Institution
Course

Content preview

*1. What is the output of `print("Hello" + 1)` in Python?*
ANS: Error (TypeError)

*2. What is the purpose of the `break` statement in a loop?*
ANS: To exit the loop prematurely

*3. Write a Python program to print the first 5 natural numbers.*
ANS: `for i in range(1, 6): print(i)`

*4. What is the difference between `=` and `==` operators?*
ANS: `=` is for assignment, `==` is for comparison

*5. What is the output of `print(5 % 2)`?*
ANS: 1

*6. Write a Python function to check if a number is even.*
ANS: `def is_even(n): return n % 2 == 0`

*7. What is the purpose of the `continue` statement in a loop?*
ANS: To skip the current iteration and move to the next one

*8. What is the output of `print("Hello".upper())`?*
ANS: HELLO

*9. Write a Python program to calculate the sum of two numbers.*
ANS: `a = 5; b = 3; print(a + b)`

*10. What is the difference between a list and a tuple in Python?*
ANS: Lists are mutable, tuples are immutable

*11. What is the time complexity of searching an element in a sorted array?*
ANS: O(log n) using binary search

*12. What is a linked list?*
ANS: A data structure in which elements are linked using pointers

*13. Write a Python program to implement a stack using a list.*
ANS: `stack = []; stack.append(1); stack.pop()`

*14. What is a queue?*
ANS: A First-In-First-Out (FIFO) data structure

*15. What is the difference between a stack and a queue?*
ANS: Stack is LIFO, queue is FIFO

Written for

Course

Document information

Uploaded on
May 10, 2025
Number of pages
4
Written in
2024/2025
Type
OTHER
Person
Unknown

Subjects

$12.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vibhavpandey1

Get to know the seller

Seller avatar
vibhavpandey1
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
11 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions