School ICT Self Study
Absolutely Free Learning Opportunity! No Need to Spend Money! Study at Your Own Pace! Everything You Need is Right Here
UNLOCK YOUR DIGITAL FUTURE!
Free ICT Learning for Sri Lanka
🚀 Welcome to School ICT

Your Gateway to Digital Excellence

🌍
|

Imperative Programming and Control Structures in Python

174 viewsG13-09 AL ICT Python Programming
0

  1. What is the purpose of comments in a Python program?

  2. Name three primitive data types in Python.

  3. What is operator precedence, and why is it important?

  4. Write a Python program to accept a number from the keyboard and print its square.

  5. Explain the difference between selection and repetition control structures with Python examples.

Ruwan Suraweera Changed status to publish
0

Answers and Descriptions:

  1. Answer: Comments explain code for readability and future reference.
    Description: In Python, single-line comments use #, and multi-line use “””. They don’t affect execution but help developers understand code logic.

  2. Answer: Integer (int), float, string (str).
    Description: These are basic data types; int stores whole numbers, float stores decimals, and str stores text, each with specific operations.

  3. Answer: Operator precedence determines the order of operations in an expression.
    Description: For example, in 3 + 4 * 2, multiplication (*) has higher precedence than addition (+), so the result is 11, not 14. Parentheses can override precedence.

  4. Answer:

    Description: The program uses input() to get a number, converts it to an integer, calculates its square, and prints the result.

  5. Answer: Selection chooses a path based on a condition (e.g., if); repetition repeats code (e.g., while).
    Description: Example: if x > 0: print(“Positive”) is selection, executing once if true. while x < 5: x += 1 is repetition, looping until the condition is false.

Ruwan Suraweera Changed status to publish
🔴 Lesson List
SIDE BUTTON ON
Sign In Register
×

👋 Welcome Back!

🚀
Ready to Learn?Pick up where you left off.
🔑
Forgot Password?Click the link below to reset.
📢
New FeaturesCheck out the new AI Voice tool.

Sign In

👤
🔒
or continue with
Google Facebook

Already have an account? Register Now

🖥️ View Desktop Version Switch to full website view.