Computer Science

File handling

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo. File Handling in Python – Code Snippets Opening Files with open(‘example.txt’, ‘r’) as file: content = file.read() File Access Methods file.read() file.readline() file.readlines() Writing Data to a File with open(‘example.txt’, ‘w’) as file: file.write(‘Hello, World!’) Binary Files …

File handling Read More »

modules in python

Python Modules Tutorial 1. Introduction to Modules import math 2. Accessing Module Functions print(math.sqrt(25)) 3. Importing Specific Functions from math import sqrt print(sqrt(25)) 4. Aliasing Modules import math as m print(m.sqrt(25)) 5. Using Multiple Functions from a Module from math import sqrt, factorial print(sqrt(25)) print(factorial(5)) 6. Understanding the Module Search Path import sys print(sys.path) 7. …

modules in python Read More »

How to calculate algorithmic efficiency?

How to Calculate Algorithmic Efficiency of a Program To calculate the algorithmic efficiency of a program, you must consider both its time complexity and space complexity. Here is a step-by-step approach: Determine the Basic Operations: Identify the basic operations of the algorithm. These are the operations that contribute most significantly to the total running time, …

How to calculate algorithmic efficiency? Read More »

Algorithmic effieciency

Understanding Algorithmic Efficiency Introduction Algorithmic efficiency refers to how effectively an algorithm performs, particularly regarding time taken to complete and the memory space it requires. It’s often discussed in terms of time complexity and space complexity, which help us to understand an algorithm’s performance with respect to the size of its input data (denoted as …

Algorithmic effieciency Read More »

Searching and sorting in python

Python Tutorial: Searching and Sorting Algorithms Introduction In this tutorial, we’ll explore two fundamental algorithms in computer science: searching and sorting. We’ll cover linear search and binary search for finding elements in a list, as well as bubble sort and quicksort for ordering lists. 1. Linear Search Linear search is a straightforward algorithm that inspects …

Searching and sorting in python Read More »

current working directory

Changing and Getting Working Directory in Python To work with directories in Python, you need to use the os module. Here’s how you can get and change the current working directory: Getting the Current Working Directory import os # Get the current working directory current_directory = os.getcwd() print(‘Current Directory:’, current_directory) Changing the Current Working Directory …

current working directory Read More »

File handling

Topics Covered in File Handling in Python Introduction to File Handling in Python Definition of a File & Different Types of Files Opening Files using the open() Function Using the with Statement for File Operations File Access Methods Reading Data from a File Writing Data to a File Input, Output, and Error Streams in Python …

File handling Read More »

Scroll to Top