0% found this document useful (0 votes)
5 views5 pages

Ict assignment

The document provides an overview of basic programming concepts in Python, including definitions of variables, identifiers, data types, and operators. It explains the differences between statements and expressions, as well as how to use the print() function in both interactive and text editor environments. Additionally, it includes examples of arithmetic operations, data type conversion, and simple programs for calculating the product of two numbers and BMI.

Uploaded by

betigistyemane64
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)
5 views5 pages

Ict assignment

The document provides an overview of basic programming concepts in Python, including definitions of variables, identifiers, data types, and operators. It explains the differences between statements and expressions, as well as how to use the print() function in both interactive and text editor environments. Additionally, it includes examples of arithmetic operations, data type conversion, and simple programs for calculating the product of two numbers and BMI.

Uploaded by

betigistyemane64
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/ 5

ICT GRADE 11 B GROUP 2 :

1. What is a variable?

A variable: is a name used to store data in a program. It acts like a container that holds
information which can change during the program.
For example:
age = 18
Here, age is a variable that stores the value 18.

2. What is an Identifier?

An identifier is the name used to identify variables, functions, classes, modules, etc. It must
follow certain rules like:

Example: total, user_name, value2 are all valid identifiers.

3. Define data type? Give an example.

A data type tells us what kind of data a variable holds. Python has different data types like:
-.Integer (int)
-.Floating-point (float)
-.String (str)

Example:
name = "Betigist" —-------------- string type
age = 18 —------------------- integer type
height = 1.75 —------------------ float type

4. What are floating number?

Floating numbers (floats) are numbers with decimal points. They are used when we want
more precious than whole number.
In Python, this type is called float.
Example:-
pi= 3.14
weight = 52.5

5. What are built-in data types?

Built-in data types: are types that Python already provides. Common ones include:
●. int for whole numbers
●. float for decimal numbers
●. str for text (string)
●. bool for true/false
●. list, tuple, dict, set for collections of data

6. Use print() function and display my name "Betigist Yemane" on the screen using
interactive interpreter
In the interactive interpreter (like the Python shell), you just type this and press Enter:

print("Betigist Yemane")

7. What is the difference between Python’s interactive interpreter and text editor?

Interactive interpreter:- lets you run one line at a time and see the result immediately. It is
useful for quick tests.

Text editor:- is used to write full Python programs saved in .py files. You run the whole
program after writing.

8. Use the print() function to display my name "Betigist Yemane" on the screen using
text-editor
In a text editor, write the following in a file (like myname.py):

print("Betigist Yemane")

Then save and run the file using Python.

9. Identify the valid identifiers and explain why they are so:
Let’s analyze each one:

A. x – Valid (It's a single letter and follows all rules)


B. _|_x – Invalid (It includes a vertical bar | which is not allowed in identifiers)
C. _X – Valid (Starts with an underscore and uses a capital letter, which is fine)
D. X*y – Invalid (It uses * which is a multiplication operator, not. allowed in names)

10. Define the use of the following arithmetic operators in Python:

Floor Division (//)


-. This operator divides two numbers and gives only the whole number part.
It removes everything after the decimal point.
Example: 7 // 2 gives 3.
It’s useful when you don’t want decimals in the result.

Modulus (%)
-.This gives the remainder after dividing two numbers.
Example: 7 % 2 gives 1.
It is commonly used to check if a number is even or odd.

Concatenation (+)
-. The + operator joins two strings together.
Example: "Hello " + "Betigist" becomes "Hello Betigist".
It is only used with text (strings), not with numbers in this case.

Exponentiation (**)
-. This operator raises a number to the power of another.
Example: 2 ** 3 means 2³, which equals 8.
It is used when you want to multiply a number by itself multiple times.
11. Define data type conversion and list the two types:

Data type conversion means changing one data type into another.
In Python, you might change a number to a string or vice versa.

Two types of conversion:


-.Implicit Conversion
Python automatically changes one type to another when needed.
Example: a = 3 + 2.5 → Python changes 3 to 3.0 automatically.

-.Explicit Conversion
You convert data types yourself using functions like int(), str(), or float().
Example: age = int("18") changes the string "18" to the number 18.

12. What is a statement?

A statement: is a complete instruction that Python can execute.


It tells Python to do something, like assign a value or print.
Example: x = 5 or print("Hi") are statements.
Statements don’t return a value, they perform an action.
They are the building blocks of Python programs.
Each line in a program is usually a statement.

13. What is an expression in Python? List 3 types with examples:

An expression: is any combination of variables, values, and operators.


It always returns or calculates a result.
Example: 2 + 3, x * y, name + " World"
Three types of expressions:
1. Arithmetic expression: 4 + 5
2. Relational expression: a > b
3. Logical expression: a > 5 and b < 10

Expressions are often used inside statements.

14. What is the difference between statement and expression?

Feature Statement Expression

Meaning Performs an action returns a value

Example X=10 4+6

Result May not return anything Always returns a result


Use Build the structure of the Used inside statements
program

Statements do something;
Expressions produce something.

15. Identify the statements from the list:

x=4*3 # Statement
y = "Programming is fun" # Statement
print(y) # Statement
z=x/2 # Statement
print(z) # Statement
y = 10 # Statement
print(type(x)) # Statement

All of these are statements because they perform an action.

16. Identify the statements that produce outputs:

Only the lines that use print() will show something on the screen.
-.print(y)
-.print(z)
-.print(type(x))

17.When the code given in activity 16 is executed, what would be the out-put on the
screen?

Here’s the step-by-step execution and output:


1. x = 4 * 3 → x becomes 12
2. y = "Programming in Python is fun" → y is now a string
3. print(y) → Output:Programming in Python is fun
4. z = x / 2 → z = 12 / 2 = 6.0 (a float)
5. print(z) → Output:6.0
6. y = 10 → now y becomes an integer (overwrites the string)
7. print(type(x)) → x = 12 is an integer Output: <class 'int'>

Final Output on the Screen:

Programming in Python is fun


6.0
<class 'int'>

18. Program to accept two numbers and display the product:

num1 = float(input("Enter first number: "))


num2 = float(input("Enter second number: "))
product = num1 * num2
print("The product is:", product)

This code asks the user for two numbers and shows the multiplication result.

19. Program to calculate and display BMI:

weight = float(input("Enter your weight in kg: "))


height = float(input("Enter your height in meters: "))
bmi =weight / (height * height)
print("Your BMI is:", bmi)

This program uses the formula:


BMI = weight / (height²)

It tells you if you're underweight, normal, or overweight.

You might also like