0% found this document useful (0 votes)
4 views6 pages

Revision Sheet For Class 12 Computer Scienc

The document is a Comprehensive Revision Sheet for Class 12 Computer Science, focusing on File Handling, Functions, and Python Basics from Class 11. It includes key concepts, example questions with answers for each topic, and a bonus section for common file functions. The revision sheet emphasizes the importance of consistent practice for success in the subject.

Uploaded by

patelanushka466
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Revision Sheet For Class 12 Computer Scienc

The document is a Comprehensive Revision Sheet for Class 12 Computer Science, focusing on File Handling, Functions, and Python Basics from Class 11. It includes key concepts, example questions with answers for each topic, and a bonus section for common file functions. The revision sheet emphasizes the importance of consistent practice for success in the subject.

Uploaded by

patelanushka466
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Here's your Comprehensive Revision Sheet for Class 12 Computer Science, covering:

File Handling (Text Files only)

Functions

Python Basics (Class 11 revision)


Each topic includes:

Key Concepts

2 Example Questions with Answers

1. PYTHON BASICS (Class 11 Revision)


Key Concepts:

Indentation: Controls code blocks (Python uses spaces or tabs).

Variables: Containers for storing data.

Data Types: int, float, str, bool, list, tuple, dict, etc.

Operators: +, -, *, /, //, %, **, comparison (==, !=, etc.)

Input/Output:
input() returns string input

print() displays output

Type Casting:

int("5"), str(7), float("3.5")

Example 1:

Q: What will be the output?

a=5
b=2
print(a // b, a % b)

A:

21

Example 2:

Q: Write a Python program to take a number as input and print its square.
A:

num = int(input("Enter a number: "))


print("Square is", num ** 2)
2. FUNCTIONS (Class 12)
Key Concepts:

Defining Function:

def func_name(parameters):
# block
return result

Calling Function: func_name(arguments)

Parameters vs Arguments:

Parameter: variable in definition

Argument: value passed during call

Default Parameters:

def greet(name="User"):
print("Hi", name)

Return vs Print:
return sends data back to caller, print displays it on screen.

Example 1:

Q: Write a function greet() that prints “Hello Python!”


A:

def greet():
print("Hello Python!")

greet()

Example 2:

Q: Write a function multiply(a, b=5) that returns the product of two numbers.
A:

def multiply(a, b=5):


return a * b

print(multiply(4)) # Output: 20

3. FILE HANDLING (Text Files Only)


Key Concepts:

Opening a file:

open(filename, mode)

Modes:

'r' = read

'w' = write (overwrites)

'a' = append
'r+' = read + write

Reading:

read() – full content

readline() – one line

readlines() – list of all lines

Writing: write("text")

with statement: auto-closes the file safely.

Closing a file: file.close()

Example 1:

Q: Write a program to write "Hello File" to "sample.txt" using with statement.


A:

with open("sample.txt", "w") as f:


f.write("Hello File")
Example 2:

Q: Write a program to read and print all lines from "sample.txt"


A:

with open("sample.txt", "r") as f:


for line in f:
print(line.strip())

BONUS: Common File Functions Quick Reference


Function Use
f.read() Read entire file as one string
f.readline() Read one line at a time
f.readlines() Returns list of lines
f.write("...") Writes string to file
f.close() Closes the file
with open(...) Automatically handles closing

Let me know if you'd like:

A PDF version of this revision sheet

Flashcards for quick recall

Another practice test to apply this knowledge

You're well on track for success — stay consistent and practice smart!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy