Posts

Plotting Graph by Keyboard Input using Python

Image
Introduction to 2D Smooth Graph Connecting line between two points ( x 1 , y 1 ) and ( x 2 , y 2 ) is known as a graph. A non-uniform cartesian co-ordinates points will generate a rigid line, which looks ugly. In Python, a rigid graph can be regenerated into a smooth graph by interpolating more points using SciPy module. SciPy (Scientific Python library) generates more sub-points based on the input array values to form a smooth curve. In this program, I have used input() function to get n number of points ( x , y ) from the user through keyboard ( screenshot is given in the bottom ) and store it to arrays. The co-ordinates points used in the program are (1, 2), (2, 5), (3, 3), (4, 6), (5, 7), (6, 2), (7, 10), (8, 5), (9, 6), and (10, 3). Program Implementation In this tutorial, I have used Python 3.5.2 (64-bit) software, and 7 modules: MatPlotLib 2.0.2 , PyParsing 2.2.0 , Python-DateUtil 2.6.1 , PyTZ 2017.2 , SetupTools 36.2.0 , Cycler 0.10.0 , SciPy 0.19.1 , and NumPy-MKL 1.13...

Polynomial Graph using Python

Image
Introduction to Polynomial Graph Polynomial curve a is smooth and continues line of graph, connected by a series of co-ordinates calculated using a polynomial equation (For example, y = f ( x ), where f ( x ) = A x 2 + B x + C). In this program, I have used a polynomial equation y = 3 x 2 + 4 x + 2 with x values range from 0 to 5. The program generated co-ordinate points ( x , y ) in the graph will be (0, 2), (1, 9), (2, 22), (3, 41), (4, 66), and (5, 97). Program Implementation In this tutorial, I have used Python 3.5.2 (64-bit) software, and 7 modules: MatPlotLib 2.0.2 , PyParsing 2.2.0 , Python-DateUtil 2.6.1 , PyTZ 2017.2 , SetupTools 36.2.0 , Cycler 0.10.0 , and NumPy-MKL 1.13.1 implemented in Windows 10 Enterprise operating system. The 7 modules are chosen based on the compatibility of Python and OS version and bit. Source Code import numpy as np import matplotlib.pyplot as plt a = 3 b = 4 c = 2 x = np.linspace(0, 10, 256, endpoint = True) y = (a * (x * x)) + (b ...

Sine and Cosine Graph using Python

Image
Introduction to Sine/Cosine Graph The sine and cosine graphs are almost identical, except the cosine curve ( y = cos ( x )) starts at amplitude y = 1, when angle x = 0° (whereas the sine curve ( y = sin ( x )) starts at amplitude y = 0). We say the cosine curve is a sine curve which is shifted to the left by 90°. The graph of sine and cosine is like a wave that forever oscillates between -1 and 1, in a shape that repeats itself every 360° (2π) units. Program Implementation In this tutorial, I have used Python 3.5.2 (64-bit) software, and 7 modules: MatPlotLib 2.0.2 , PyParsing 2.2.0 , Python-DateUtil 2.6.1 , PyTZ 2017.2 , SetupTools 36.2.0 , Cycler 0.10.0 , and NumPy-MKL 1.13.1 implemented in Windows 10 Enterprise operating system. The 7 modules are chosen based on the compatibility of Python and OS version and bit. Source Code import numpy as np import matplotlib.pyplot as plt X = np.linspace(-np.pi, np.pi, 256, endpoint = True) C, S = np.cos(X), np.sin(X)...

Exponential Graph using Python

Image
Introduction to Exponential Graph Exponential curve a is smooth and continues line of graph, connected by a series of co-ordinates calculated using a polynomial equation containing variable exponential value (For example, y = f ( x ), where f ( x ) = A e B x + C). In this program, I have used a polynomial equation with a exponential variable y = 5 e -2 x + 1 with x values range from 0 to 10. The program generated co-ordinate points ( x , y ) in the graph will be (0, 6.0), (1, 1.7), (2, 1.1), (3, 1.0), (4, 1.0), (5, 1.0), (6, 1.0), (7, 1.0), (8, 1.0), (9, 1.0), and (10, 1.0). Program Implementation In this tutorial, I have used Python 3.5.2 (64-bit) software, and 7 modules: MatPlotLib 2.0.2 , PyParsing 2.2.0 , Python-DateUtil 2.6.1 , PyTZ 2017.2 , SetupTools 36.2.0 , Cycler 0.10.0 , and NumPy-MKL 1.13.1 implemented in Windows 10 Enterprise operating system. The 7 modules are chosen based on the compatibility of Python and OS version and bit. Source Code import numpy as...

Converting XAMPP into XAMPPP

Image
This tutorial explains about a simple method to configure Apache, PHP, MySQL, Perl and Python in windows platform. In this tutorial, I have used the latest operating system (Windows 8.1 Enterprise Edition 64-bit) and latest softwares - XAMPP 1.8.3 and Python 3.3.0. Refer official site of XAMPP and Python for installation instructions. XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. The XAMPP 1.8.3 contains of Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql. The default configuration of Apache is perfectly linked with MySQL, PHP and Perl. Since Perl and Python run under common gateway interface (CGI), configuring Python CGI with XAMPP is very easy. To convert XAMPP into XAMPPP, we have to change the existing AddHandler Apache configuration command to AddHa...

Finding Smallest of Two Numbers using Class in C++

Image
This is a simple tutorial for computing smallest of two numbers using the classes and objects in C++. In this tutorial, I have used Dev C++ v5.11 software for compiling the C++ program. Classes and Objects in C++ In C++ language, Object Oriented Programming (OOP) is a concept introducted to class ify or organize data into objects. A class is a user defined type or data structure declared with keyword class that has data and functions (also called methods) as its members whose access is governed by the three access specifiers private , protected or public (by default access to members of a class is private ). The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class. Instances of a class data type are known as objects and can contain member variables, constants, member functions, and overloaded operators defined by the programmer. Sour...

Power of a Number using C++ Function Overloading

Image
This article explains the different types of function overloading methods to compute the power of a number ( x n ) using C++. In this tutorial, I have used Dev C++ v5.11 software for compiling the C++ program. Overloading in C++ In C++ language, overloading is a method used to define more than one functions ( function overloading ) or operators ( operator overloading ) with the same name and different data types or parameters. Example for function overloading, add (int a, int b) add (int a, int b, int c) add (float a, float b) add (float a, int b) Example for operator overloading, Increment i(5); // Class declaration and input value i++; // Calling of a function "void operator++()" which assigns x += 5; i.Print(); // Output is 10 Source Code // Computing m^n using function overloading. #include <iostream> #include <conio.h> using namespace std; long double power (double m, int n) { long double x = 1; for (int i = 0; i < n; i++) { x *=...