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

🌍
|

File Operations, Database Interaction, and Algorithm Efficiency

189 viewsG13-09 AL ICT Python Programming
0

  1. What are the basic file operations in Python?

  2. Write a Python program to write a string to a file and read it back.

  3. How can Python connect to a MySQL database to retrieve data?

  4. What is sequential search, and when is it used?

  5. Write a Python program to implement bubble sort on a list of numbers.

Ruwan Suraweera Changed status to publish
0

Answers and Descriptions:

  1. Answer: Open, close, read, write, append.
    Description: These operations allow file handling in Python. open() accesses a file, read()/write()/append() manipulates content, and close() releases resources.

  2. Answer:

    Description: The program uses with to safely open a file, writes a string in write mode (“w”), and reads it back in read mode (“r”).

  3. Answer: Use the mysql.connector module to connect, execute SQL queries, and fetch data.
    Description: Example:

    This connects to a MySQL database, retrieves all records from the students table, and closes the connection.

  4. Answer: Sequential search checks each element in a list until the target is found or the list ends.
    Description: It’s simple but inefficient for large datasets, used when data is unsorted or small.

  5. Answer:

    Description: Bubble sort compares adjacent elements and swaps them if out of order, repeating until sorted. It’s simple but inefficient for large lists.

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.