All Blogs

Deploying an existing Django project on PythonAnywhere

Deploying a Django project on PythonAnywhere is a straightforward process. PythonAnywhere provides a platform for hosting web applications and is well-suited for hosting Django projects. Here’s a step-by-step guide to deploying your Django project on PythonAnywhere: Step 1: Sign Up for a PythonAnywhere Account If you don’t already have an account on PythonAnywhere, sign up …

Deploying an existing Django project on PythonAnywhere Read More »

Python NumPy Library

NumPy Library NumPy is an open-source Python library for numerical computations. It stands for “Numerical Python.” NumPy provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays efficiently. It is a fundamental library for data science and scientific computing in Python. Key features of NumPy …

Python NumPy Library Read More »

Python Pandas Library

Pandas Library Pandas is an open-source Python library that provides powerful and flexible data structures and data analysis tools. It is widely used in data manipulation, data cleaning, data transformation, and data analysis tasks. The name “Pandas” is derived from “Panel Data,” which refers to multi-dimensional structured data. Key features of Pandas: DataFrame: The DataFrame …

Python Pandas Library Read More »

M.Sc Python Programming Assignment 31

M.Sc Python Programming Assignments Assignment 31 Question: Write a Python class named Circle constructed by a radius and two methods which will  compute the area and the perimeter of a circle Code: import math class Circle: def __init__(self, radius): self.radius = radius def compute_area(self): return math.pi * self.radius ** 2 def compute_perimeter(self): return 2 * …

M.Sc Python Programming Assignment 31 Read More »

M.Sc Python Programming Assignment 30

M.Sc Python Programming Assignments Assignment 30 Question: Write a Python class named Rectangle constructed by a length and width and a method which will compute the area and perimeter of a rectangle. Code: class Rectangle: def __init__(self, length, width): self.length = length self.width = width def compute_area(self): return self.length * self.width def compute_perimeter(self): return 2 …

M.Sc Python Programming Assignment 30 Read More »

M.Sc Python Programming Assignment 29

M.Sc Python Programming Assignments Assignment 29 Question: Write a Python class to reverse a string word by word. Input string : ‘hello.py’ Expected Output : ‘.py hello’ Code: class StringReverser: def reverse_words(self, input_string): words = input_string.split() reversed_string = ‘ ‘.join(reversed(words)) return reversed_string # Example usage input_string = input(“Enter a string: “) reverser = StringReverser() reversed_string …

M.Sc Python Programming Assignment 29 Read More »

M.Sc Python Programming Assignment 28

M.Sc Python Programming Assignments Assignment 28 Question: Write a Python program to read a random line from a file Code: import random def read_random_line(file_name): with open(file_name, ‘r’) as file: lines = file.readlines() random_line = random.choice(lines) return random_line.strip() # Example usage file_name = input(“Enter the file name: “) random_line = read_random_line(file_name) print(“Random line from the file:”) …

M.Sc Python Programming Assignment 28 Read More »

CRUD Operations with Django

CRUD Operations with Django In Django, CRUD (Create, Read, Update, Delete) operations are used to interact with the database and perform various data manipulation tasks. Django’s built-in ORM (Object-Relational Mapping) provides a convenient way to handle these operations. Here’s a step-by-step guide on how to use CRUD operations with Django: Assuming you have already set …

CRUD Operations with Django Read More »

M.Sc Python Programming Assignment 27

M.Sc Python Programming Assignments Assignment 27 Question: Write a Python program to copy the contents of a file to another file Code: def copy_file(source_file, destination_file): with open(source_file, ‘r’) as source: with open(destination_file, ‘w’) as destination: for line in source: destination.write(line) print(“File copied successfully!”) # Example usage source_file = input(“Enter the source file name: “) destination_file …

M.Sc Python Programming Assignment 27 Read More »

Tech Amplifier Final Logo