Posts

Showing posts with the label source code

Math Functions : Beginner's Level

Image
In this blog post, we will see how can we create simple Mathematics functions by using python programming Language, so here we go... #You can add comments in the below code and share it in the comment box :) #comments make the code easy to understand def add(a,b): return(a+b) def sub(a,b): return(a-b) def div(a,b): if a == b: return 1 elif b == 0: return ("Math Error: division by zero") else: return(float(a//b)) def mult(a,b): return(a*b) def power(a,b): c = 1 for p in range(0,b): c *= a return(c) def main(): print("-------------------------------------------") print("The available functions are the following: ") print("1-Addition\n2-Subtraction\n3-Division\n4-Multiplication\n5-Power") counter = 0 while(counter < 20): print("-------------------------------------------") print("") option = input("Enter the number from 1-5 corresponding to the above fu...

Hollow Diamond

Image
Drawing different shapes with the help of coding is quite  enjoyable and interesting. Mostly the first semester students of software engineering encounter with this. so, let us learn, how to draw a hollow diamond using python? First of all declare variables: Diamond consists of two cones , upper cone with pointed top and lower cone with pointed bottom . so let us write the code for the upper cone, but the cone must be hollow: The resultant of this code is as under: Now, write the code for lower hollow cone: The output for this code is: Now, run both the codes simultaneously, and the output is: the reason for this output: This is one of the possibilities of writing code, to get this output. There might be other ways of doing the same task. Keep finding and trying different ways of coding. And do remember: Programming language doesn't matter but logic matters . So, work mainly on logic building .

Calculator Using Python 3

Image
Today I will show you how you can make a simple calculator using python 3, I made this in my 1st semester, kindly find the code below and make sure to understand it well: import math print(" >>> CONSOLED BASED CALCULATOR >>> \n " ) print("This is a consoled Based Calculator , This allowed a user to perform the \n under lying operations:") print(" >>> Addition \n >>> Subtraction \n >>> Multiplication \n >>> Division \n >>> log \n >>> exponent ") print("this is also specially designed for the convertion of a number from degree to radian and vice versa") print("More Over the calculator also allows the user to perform 'TRIGNOMETRIC AND HYPERBOLIC FUNCTIONS' \n like : cos,sin,tan and inverse of all \n also cosh,sinh,tanh and their inverses ") print("'SO GO ON AND US...