Posts

Showing posts with the label python

Simple Calculator in Python

Image
                    Simple Calculator in Python     We are going to write code for a simple calculator in python, It will show you that how can you use basic python statements and function to make a calculator that will do addition, subtraction,multiplication and division. Calculator python coding: def add (a , b): return a + b def subtract (a , b): return a - b def multiply (a , b): return a * b def divide (a , b): return a / b print ( "Select Desired Operation." ) print ( "1.Add" ) print ( "2.Subtract" ) print ( "3.Multiply" ) print ( "4.Divide" ) while True : choice = input ( "Enter choice(1/2/3/4): " ) if choice in ( '1' , '2' , '3' , '4' ): num1 = float ( input ( "Enter first number: " )) num2 = float ( input ( "Enter second number: " )) if choice == '1' : print (num1 , "+" , num2 , "=...

Learning Basics of Python

Image
                             Python Basics What is VARIABLES in Python? As the name implies the meaning, a variable is something which can be change. A variable is a way of referring to a memory location used by a computer program. A variable is a symbolic name for this physical location. This memory location contains values, like numbers,text or more complicated types. Variables can be treated as a container which can store some value in it. In any other languages for example C++, This is how you write a variable int a = 20 Where int is data type of the variable. Int stands for integer. String refers to text or collection of characters. It is represented in single quotes or double quotes. Float refers to decimal point numbers. In Programming languages like C++ you have to specify the data type of a variable. But in python you don’t have to worry about data type. Whatever value  you give the variable, python...