0% found this document useful (0 votes)
11 views8 pages

Chapter 1

The document provides an introduction to programming, explaining its purpose, the evolution of programming languages, and the basics of Python. It covers key concepts such as variables, data types, operators, conditional statements, and loops in Python, along with the reasons for Python's popularity in various fields. Additionally, it includes multiple-choice and short-answer questions to reinforce understanding of the material.
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)
11 views8 pages

Chapter 1

The document provides an introduction to programming, explaining its purpose, the evolution of programming languages, and the basics of Python. It covers key concepts such as variables, data types, operators, conditional statements, and loops in Python, along with the reasons for Python's popularity in various fields. Additionally, it includes multiple-choice and short-answer questions to reinforce understanding of the material.
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

Chapter 1: Basics of Programming

What is Programming?
Programming is the art of writing instructions that a computer can understand
and execute. These instructions are written in a programming language, and
they guide the computer to perform specific tasks like calculations, displaying
output, or handling data. Programming is the core skill behind all software
applications we use today.
Why Do We Need Programming?
We need programming because computers do not work by themselves. They
need a clear set of instructions. With programming, we can create:
 Websites
 Games
 Applications
 Robots and automation tools
It helps us automate daily tasks, solve problems quickly, and build intelligent
systems.
History of Programming Languages:
1. Machine Language – First generation, written using binary digits (0s and
1s). Very hard to write and understand.
2. Assembly Language – Used short English-like commands (like ADD,
SUB), easier than binary but still close to the hardware.
3. High-Level Languages – Examples: Python, C, Java. These are easy to
write, read, and understand. They are translated into machine language
using interpreters or compilers.

Chapter 2: Introduction to Python


What is Python?
Python is a popular high-level programming language created by Guido van
Rossum in 1991. It is known for its simple and clear syntax that closely
resembles English. Python makes it easy for beginners to start coding while also
being powerful enough for professionals to build advanced applications.
Features of Python:
 Readable: Python syntax is clean and easy to understand.
 Interpreted: Python runs code line-by-line, which helps in easier
debugging.
 Cross-Platform: Works on Windows, Mac, Linux, etc.
 Dynamically Typed: No need to mention data types explicitly.
 Vast Library Support: Has modules for tasks like math, file handling,
data processing, etc.
Why is Python So Popular?
Python is widely used in:
 Web Development
 Data Science and Machine Learning
 Automation and Scripting
 Artificial Intelligence
It’s used by major tech companies like Google, Instagram, and Netflix.
Because of its simplicity and demand in job markets, it is often the first language
taught in schools and universities.

Chapter 3: Python Basics


Variables:
Variables are containers that store data values. You can name a variable and
assign it a value using the = sign.
name = "Alice"
age = 14

Data Types:
Python automatically understands the type of value assigned. Common types
are:
 int – for whole numbers (e.g., 10)
 float – for decimal numbers (e.g., 3.14)
 str – for text (e.g., "Hello")
 bool – for logical values (True or False)
Input and Output:
You can take user input using input() and display output using print().
name = input("Enter your name: ")
print("Hello", name)

Arithmetic Operators:
Used to perform calculations:
 + for addition
 - for subtraction
 * for multiplication
 / for division
 % for remainder (modulus)
print(5 + 3)
Comparison Operators:
Used to compare two values and return True or False:
 == equals
 != not equal
 > greater than
 < less than
 >= greater or equal
 <= less or equal
print(10 > 5)

Conditional Statements:
Used to make decisions in your program.
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

Loops:
Loops are used to repeat a block of code.
While Loop:
Repeats as long as a condition is true.
i = 1
while i <= 3:
print(i)
i += 1

For Loop:
Repeats for a specific number of times.
for i in range(1, 4):
print(i)

Comments:
Used to explain code; Python ignores them during execution.
# This is a comment

30 MCQs – Based on Material


1. Programming is used to:
A. Cook food
B. Control machines
C. Sing songs
D. Drive cars
2. The first type of programming language was:
A. Python
B. Java
C. Machine Language
D. C++
3. Assembly language uses:
A. Binary digits
B. Emojis
C. Mnemonic codes
D. Sound signals
4. Python was created in:
A. 1989
B. 1991
C. 2001
D. 1999
5. The creator of Python is:
A. Elon Musk
B. Charles Babbage
C. Guido van Rossum
D. Bill Gates
6. Python is a:
A. Low-level language
B. High-level language
C. Musical instrument
D. None
7. Python code is run:
A. Line by line
B. All at once
C. Backward
D. Randomly
8. Which is a valid variable?
A. 1name
B. name1
C. #name
D. int
9. print() is used to:
A. Take input
B. Define variables
C. Output data
D. Do nothing
[Link] is input() used for?
A. Printing output
B. Defining functions
C. Receiving user data
D. Running loops
[Link] is a correct data type in Python?
A. number
B. float
C. real
D. character
[Link] stores:
A. Text
B. Decimal
C. Whole numbers
D. Boolean
[Link] is used for:
A. Loops
B. Conditions
C. Strings or text
D. Integers
[Link] and False belong to:
A. string
B. bool
C. int
D. float
[Link] is 5 % 2?
A. 3
B. 1
C. 2
D. 0
[Link] does == do?
A. Assigns a value
B. Checks equality
C. Adds two numbers
D. None
17.!= means:
A. Equal
B. Not equal
C. Less than
D. Greater than
[Link] is a comparison operator?
A. +
B. -
C. ==
D. *
[Link] does if do in Python?
A. Create loops
B. Print text
C. Make decisions
D. Comment code
[Link] keyword is used with if for an alternative condition?
A. elif
B. else
C. both
D. end
[Link] does a loop do?
A. Stops code
B. Prints comments
C. Repeats code
D. Checks types
[Link] loop repeats while a condition is true?
A. for
B. while
C. repeat
D. until
[Link] loop uses range()?
A. for
B. while
C. input
D. if
[Link] is # used for?
A. Variable
B. Comment
C. Loop
D. Input
[Link] is the result of print(4 > 5)?
A. Error
B. True
C. False
D. 4
[Link] is:
A. Interpreted
B. Compiled only
C. Binary based
D. Slow
[Link] company uses Python?
A. Google
B. Netflix
C. Instagram
D. All of these
[Link] uses ______ indentation.
A. curly braces
B. brackets
C. whitespace
D. tabs only
[Link] data type would store "Python"?
A. int
B. str
C. bool
D. float
[Link] is the default start of range(n)?
A. 1
B. 0
C. n
D. Undefined

30 Short Answer (3-mark) Questions


1. What is the purpose of programming?
2. Explain machine language with an example.
3. What are the differences between assembly and high-level languages?
4. Who created Python and why?
5. List any three reasons why Python is easy for beginners.
6. Explain why Python is in demand in industries.
7. What is a variable? Give one example.
8. Mention any four data types in Python with examples.
9. Write a program to take user input and display a greeting.
[Link] the role of the print() function in Python.
[Link] and explain any four arithmetic operators.
[Link] does the % operator do in Python?
[Link] is the use of comparison operators? Write two examples.
[Link] is the difference between = and == in Python?
[Link] a Python if-else statement to check if a number is positive.
[Link] does Python decide what code to run in an if block?
[Link] is the purpose of a while loop?
[Link] a loop to print numbers from 1 to 3 using while.
[Link] the syntax of the for loop with range().
[Link] a for loop to print numbers from 5 to 7.
[Link] are comments in Python? Why are they used?
[Link] happens if we forget indentation in Python?
[Link] dynamic typing with an example.
[Link] a Python program to add two numbers.
[Link] is the use of the input() function? Write one example.
[Link] how Python is platform-independent.
[Link] is Python considered an interpreted language?
[Link] any two differences between low-level and high-level languages.
[Link] any two companies that use Python and why.
[Link] does the bool data type store? Give examples.

You might also like