Skip to main content

Posts

Why Learn Python?

Python is an easy-to-learn programming language that has some really useful features for a beginning programmer. The code is quite easy to read when compared to other programming languages, and it has an interactive shell into which you can enter your programs and see them run.  In addition to its simple language structure and an interactive shell with which to experiment, Python has some features that greatly augment the learning process and allow you to put together simple animations for creating your own games. One is the turtle module, inspired by Turtle graphics (used by the Logo programming language back in the 1960s) and designed for educational use. Another is the tkinter module, an interface for the Tk GUI toolkit, which provides a simple way to create programs with slightly more advanced graphics and animation.
Recent posts

Why learn computer programming?

  Programming fosters creativity, reasoning, and problem-solving. The programmer gets the opportunity to create something from nothing, use logic to turn programming constructs into a form that a computer can run, and, when things don’t work quite as well as expected, use problem solving to figure out what has gone wrong. Programming is fun, sometimes challenging (and occasionally frustrating) activity, and the skills learned from it can be useful both in school and at work.   Even if your career has nothing to do with computers. And, if nothing else, programming is a great way to spend an afternoon when the weather outside is dreary.

Factorial Program in Python

What is Factorial Program? Factorial Program in C: Factorial of n is   the product of all positive descending integers . Factorial of n is denoted by n!. For example: 5! = 5*4*3*2*1 = 120. How do you code a factorial for a loop in Python? num = int(input("enter a number: ")) fac = 1. for i in range(1, num + 1): fac = fac * i. print("factorial of ", num, " is ", fac) Factorial Program in Python # Python program to find the factorial of a number provided by the user. # change the value for a different result num = 7 # To take input from the user #num = int(input("Enter a number: ")) factorial = 1 # check if the number is negative, positive or zero if num < 0 : print ( "Sorry, factorial does not exist for negative numbers" ) elif num == 0 : print ( "The factorial of 0 is 1" ) else : for i in range( 1 ,num + 1 ): factorial = factorial*i print ( "The factorial of" ,num, "is"

Features of python

  Python   is a dynamic, high-level, free open source, and interpreted programming language. It supports object-oriented programming as well as procedural-oriented programming. In Python, we don’t need to declare the type of variable because it is a dynamically typed language. For example, x = 10 Here, x can be anything such as String, int, etc. Features in Python There are many features in Python, some of which are discussed below – 1. Easy to code: Python is a high-level programming language. Python is very easy to learn language as compared to other languages like C, C#, Javascript, Java, etc. It is very easy to code in the python language and anybody can learn python basics in a few hours or days. It is also a developer-friendly language. 2. Free and Open Source: Python language is freely available on the official website and you can download it from the given download link below click on the  Download Python  keyword. Download Python Since it is open-source, this means that source

Code 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 , "=" , add(num1 , num2)) elif choice == 

Using input command in python

Today i will show you that how can you use input command in python language, so we will write a simple program that will ask for any name or value and then print that name or value. So here is our simple program. a= input ( "Enter your name" ) print (a) as you can see we have declared "a" a variable that will ask for input "Enter your name" and then print command will print the variable "a". So anything we will type will be printed. As show in the picture below. But here you have to remember, if you are working with integers for some mathematical work than you have to declare input type as integer because then python will take input type as integer and not as word. As show in the picture below. As you can see the syntax that how can we declaring the input type,,int, we have to write int then in brackets we have to enter the input command, int stands for integer and it will declare our input as integer, we have and in print command we have instruc

Writing first python program

  We are here to write our first program,it will  be an easy program just printing the entered word or value. The syntax of python language is very simple and easy and you dont have to confuse your mind with any complexity. So here is our first program print ( "Hello my name is abc" ) print command is used to display the output written in brackets with inverted commas. As we have typed the sentence "Hello my name is abc". So this command will simply print this sentence as show above in the picture.