PythonSample

Python and MariaDB: How to access Maria Database with Python

Database table : Customer table with following columns. database.py :  Create database connection and close connection. # -*- coding: utf-8 -*- """ Created on Tue Jul 24 09:40:55 2018 @author: n0r0082 """ fro…

Python os module- File operations in Python using python os module

Python provides os module which can be used to perform File operations like - create, read, write and delete. Below program performs following operation - 1. Check for a directory and create if it does not exist 2. Create a file . 3. Write into fi…

Vector Arithmetic in Python : Dot product and Cross product

Write a sample program to perform Addition(+), Subtraction(-), Dot product,Cross product between two vectors. Also find angle between two vectors. from math import * class vector : def __init__ ( self , x, y, z): self . x = floa…

Operator overloading in python: Python Arithmetic on Complex numbers

Write a sample program to perform Addition(+), Subtraction(-), Multiplication(*),Division(/) between complex numbers. And also perform Mod (underRoot(Square(real)+square(imaginary))) of complex number.  from math import pow class complex : …

Simulate Unix GREP command in Python

Grep command  :- Grep searches the named input FILE's (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.takes 2 parameters "so…

Sort array of objects using Comparator in python

Problem :- Given an array of  Student objects, sort array using a comparator that sorts them in order of decreasing marks; if  or more students have the same marks, sort those students alphabetically by name. Input :- Array of Student objects(Student…

Load More
That is All