Call Us Now!
+91 9884412301 | +91 9600112302
info@credosystemz.com
Credo SystemzCredo Systemz
  • Home
  • About Us
    • Online Training
    • Corporate Training
    • Events
    • Reviews
      • Video Reviews
    • Become an instructor
  • Courses
    • TRENDING TECHNOLOGIES TRAINING
    • RPA TRAINING
    • CLOUD COMPUTING TRAINING
    • BIG DATA TRAINING
    • WEB DEVELOPMENT TRAINING
    • MOBILE APPLICATION TRAINING
    • SOFTWARE TESTING TRAINING
    • MICROSOFT TECHNOLOGIES TRAINING
    • JAVA TRAINING
    • PROJECT MANAGEMENT TRAINING
    • DATA WAREHOUSING TRAINING
    • ORACLE TRAINING
    • DATABASE DEVELOPER TRAINING
    • OTHER TRAININGS
    • TRENDING TECHNOLOGIES
      Python Training Data Science Training Angular Training React JS Training ORACLE PRIMAVERA TRAINING Machine Learning Training Hadoop Training Amazon Web Services Training DevOps Training Azure Training PySpark Training MEAN Stack Training
    • RPA TRAINING
      Blue Prism Training UiPath Training Automation Anywhere
    • CLOUD COMPUTING
      Amazon Web Services Training AWS with Devops Training Azure Training AZ 104 Azure Administrator AZ 204 Azure Developer AZ 300 Azure Architect AZ 303 Azure Architect AZ 400 Azure Devops Google Cloud Platform Salesforce Training OpenNebula Training OpenStack Training OpenSpan Training
    • BIG DATA TRAINING
      Hadoop Training Big Data Analytics Training Spark Training
    • WEB DEVELOPMENT
      Angular Training Node JS Training React JS Training React Native Training Ionic Framework Training MEAN Stack Training PHP Training JavaScript Training CoffeeScript Training Less JS Training Graphics Design Training HTML Training CSS Training
    • MOBILE APPLICATION
      Android Training iOS Training iOS Swift Training Kotlin Training Flutter Dart Training
    • SOFTWARE TESTING
      Manual Testing Training UFT / QTP Training Selenium Training API Testing Training Selenium with Python Training Perfecto Mobile Testing Training ETL Testing Training JMeter Training LoadRunner Training Performance Engineering Big Data Testing Training Protractor Testing Training
    • MICROSOFT TECHNOLOGIES
      Dot Net Training MVC Framework ASP.NET MVC with Angular SharePoint Training Advanced Excel Training Excel Macro Training Azure Training Azure Infrastructure Solutions AZ 300 Azure Architect
    • JAVA TRAINING
      Core Java Training Java 8 Training Java J2EE Training Advanced Java Training Hibernate Training Spring Training Struts Training
    • PROJECT MANAGEMENT
      Oracle Primavera Training Primavera P6 Online Training Microsoft Project Training PMP Training ITIL Training Prince2 Training Scrum Master Training Business Analytics Training
    • DATA WAREHOUSING
      Tableau Training Power BI Training Qlikview Training Qlik Sense Training Informatica Training Microstrategy Training Teradata Training Cognos Training SAS Training
    • ORACLE TRAINING
      Oracle PL/SQL Training Oracle DBA Training Oracle Apps Technical Training Oracle Apps SCM Training Oracle Apps HRMS Training Oracle Apps Finance Training Oracle RAC Training PeopleSoft HCM Training PeopleSoft Finance Training
    • DATABASE DEVELOPER
      MongoDB Training Apache Cassandra Training Sybase Training Informix Training Performance Tuning Training
    • OTHER TRAININGS
      Ethical Hacking Training C C++ Training Unix Shell Scripting Training Tensorflow Training Data Modeling Training Workday Training PEGA Training Digital Marketing Training CCNA Training Arduino Training Elm Training Go Programming Training Rust Programming Training CYBER SECURITY TRAINING BIZTALK SERVER TRAINING Spoken English Course
  • Training
    • Trending Technologies Training
    • RPA TRAINING in Chennai
    • Cloud Computing Training
    • Big Data Hadoop Training in Chennai
    • Web Development Training
    • Mobile Application Training
    • Software Testing Training
    • Microsoft Technologies Training
    • Java Training
    • Project Management Training
    • Data Warehousing Training
    • Oracle Training
    • Database Developer Training
    • Other Training
  • Career Guidance
    • Interview Questions
    • Resume Building
    • Job Opportunities
  • Placements
  • Contact Us
  • Home
  • About Us
    • Online Training
    • Corporate Training
    • Events
    • Reviews
      • Video Reviews
    • Become an instructor
  • Courses
    • TRENDING TECHNOLOGIES TRAINING
    • RPA TRAINING
    • CLOUD COMPUTING TRAINING
    • BIG DATA TRAINING
    • WEB DEVELOPMENT TRAINING
    • MOBILE APPLICATION TRAINING
    • SOFTWARE TESTING TRAINING
    • MICROSOFT TECHNOLOGIES TRAINING
    • JAVA TRAINING
    • PROJECT MANAGEMENT TRAINING
    • DATA WAREHOUSING TRAINING
    • ORACLE TRAINING
    • DATABASE DEVELOPER TRAINING
    • OTHER TRAININGS
    • TRENDING TECHNOLOGIES
      Python Training Data Science Training Angular Training React JS Training ORACLE PRIMAVERA TRAINING Machine Learning Training Hadoop Training Amazon Web Services Training DevOps Training Azure Training PySpark Training MEAN Stack Training
    • RPA TRAINING
      Blue Prism Training UiPath Training Automation Anywhere
    • CLOUD COMPUTING
      Amazon Web Services Training AWS with Devops Training Azure Training AZ 104 Azure Administrator AZ 204 Azure Developer AZ 300 Azure Architect AZ 303 Azure Architect AZ 400 Azure Devops Google Cloud Platform Salesforce Training OpenNebula Training OpenStack Training OpenSpan Training
    • BIG DATA TRAINING
      Hadoop Training Big Data Analytics Training Spark Training
    • WEB DEVELOPMENT
      Angular Training Node JS Training React JS Training React Native Training Ionic Framework Training MEAN Stack Training PHP Training JavaScript Training CoffeeScript Training Less JS Training Graphics Design Training HTML Training CSS Training
    • MOBILE APPLICATION
      Android Training iOS Training iOS Swift Training Kotlin Training Flutter Dart Training
    • SOFTWARE TESTING
      Manual Testing Training UFT / QTP Training Selenium Training API Testing Training Selenium with Python Training Perfecto Mobile Testing Training ETL Testing Training JMeter Training LoadRunner Training Performance Engineering Big Data Testing Training Protractor Testing Training
    • MICROSOFT TECHNOLOGIES
      Dot Net Training MVC Framework ASP.NET MVC with Angular SharePoint Training Advanced Excel Training Excel Macro Training Azure Training Azure Infrastructure Solutions AZ 300 Azure Architect
    • JAVA TRAINING
      Core Java Training Java 8 Training Java J2EE Training Advanced Java Training Hibernate Training Spring Training Struts Training
    • PROJECT MANAGEMENT
      Oracle Primavera Training Primavera P6 Online Training Microsoft Project Training PMP Training ITIL Training Prince2 Training Scrum Master Training Business Analytics Training
    • DATA WAREHOUSING
      Tableau Training Power BI Training Qlikview Training Qlik Sense Training Informatica Training Microstrategy Training Teradata Training Cognos Training SAS Training
    • ORACLE TRAINING
      Oracle PL/SQL Training Oracle DBA Training Oracle Apps Technical Training Oracle Apps SCM Training Oracle Apps HRMS Training Oracle Apps Finance Training Oracle RAC Training PeopleSoft HCM Training PeopleSoft Finance Training
    • DATABASE DEVELOPER
      MongoDB Training Apache Cassandra Training Sybase Training Informix Training Performance Tuning Training
    • OTHER TRAININGS
      Ethical Hacking Training C C++ Training Unix Shell Scripting Training Tensorflow Training Data Modeling Training Workday Training PEGA Training Digital Marketing Training CCNA Training Arduino Training Elm Training Go Programming Training Rust Programming Training CYBER SECURITY TRAINING BIZTALK SERVER TRAINING Spoken English Course
  • Training
    • Trending Technologies Training
    • RPA TRAINING in Chennai
    • Cloud Computing Training
    • Big Data Hadoop Training in Chennai
    • Web Development Training
    • Mobile Application Training
    • Software Testing Training
    • Microsoft Technologies Training
    • Java Training
    • Project Management Training
    • Data Warehousing Training
    • Oracle Training
    • Database Developer Training
    • Other Training
  • Career Guidance
    • Interview Questions
    • Resume Building
    • Job Opportunities
  • Placements
  • Contact Us

BASIC PYTHON PROGRAMS FOR BEGINNERS WITH SOLUTION

  • Home
  • BASIC PYTHON PROGRAMS FOR BEGINNERS WITH SOLUTION

Introduction

To begin with, Python is the most in-demand programming language which is easiest to learn for beginners. This basic python program article is framed to help beginners to understand the basic concepts of python with programs and solutions. Python certification course in Chennai at Credo Systemz is a practical oriented training course which starts from the basic with the help of professional expert trainers.

Basic python programs

  • Python program to perform basic arithmetic operations
  • Python program to find the factorial of a given number
  • Python program to find the simple and compound interest
  • Python program to check whether the given number is prime or composite
  • Python program to find the biggest of three numbers
  • Python Program to display the multiplication Table
  • Python Program to Check Armstrong Number
  • Python Program to Check Whether the given String is Palindrome or Not

Python program to perform basic arithmetic operations

Basic Arithmetic operations

  • Addition
  • Subtraction
  • Multiplication
  • Division
Program

#Getting input from user
number1 = input("Enter the First number: ")
number2 = input("Enter the Second number: ")
 # Addition
sum = number1 + number2
 # To display the sum
print("Addition:" ,sum)
# Subtraction
sub = number1 -number2
# To display the subtraction
print("Subtraction:" ,sub)
# Multiplication
multiply = number1 *number2
# To display the multiplication
print("Multiplication:" ,multiply)
# Division
divide = number1 + number2
# To display the sum
print("Division:" ,divide)
Output

Enter the First number: 4

Enter the Second number: 2

Addition: 6

Subtraction: 2

Multiplication: 8

Division: 2

Python program to find the factorial of a given number

A factorial of a given number calculated by findingthe product of all the numbers from 1 to the user specified number.

Using traditional iterationmethod


# factorial of given number
def factorial(num):
    ifnum< 0:
        return 0
    elifnum == 0 or num == 1:
        return 1
    else:
        fact = 1
        while(num> 1):
            fact= fact * num
            num=num - 1
        return fact
#Getting input from user
num = input("Enter the Given number: ")
print("Factorial:",factorial(num))

Output Enter the Given number: 3

Factorial: 6

Using in-built function


import math
#Getting input from user
num = input("Enter the Given number: ")
#in-built function
fact=math.factorial(num)
print("Factorial of given number:",fact)
 
Output Enter the Given number: 4

Factorial of given number: 24

Python program to find the simple and compound interest


P = principle amount
T = time period
R = rate of interest
A =amount 
T =time span
Simple interest formula: 
(P x T x R)/100
Compound interest formula: 
A = P(1 + R/100) t 
Compound Interest = A – P 
#Getting input from user
p = input("Enter the Principle amount: ")
t = input("Enter the time period: ")
r = input("Enter the rate of interest: ")
#to calculate simple interest
SI = (p * t * r)/100
print('Simple Interest:', SI)
#to calculate compound interest
Amount = p * (pow((1 + r/ 100), t))
CI = Amount - principle
print("Compound Interest:", CI)
Output Enter the Principle amount: 5000

Enter the time period: 2

Enter the rate of interest: 5

Simple Interest: 500

Compound Interest: 5500

Python program to check whether the given number is prime or composite

The prime number is a whole number with two integral divisors i.e., divisible by 1 and itself. The composite number is a whole number with more than two integral divisors.

#Getting input from user
num = int(input("Enter a number : "))
#to check prime or composite
ifnum == 0 or 1:
print(num, "is a neither prime NOR composite number")
elifnum> 1:
fori in range(2, num):
if (num % i) == 0:
print(num, "is NOT a prime number")
break
else:
print(num, "is a PRIME number")
else:
print(num, "is a COMPOSITE number")
Output Enter a number: 3

3 is a PRIME number

Python program to find the biggest of three numbers


# Getting input from user
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))
#to find the biggest number
if (num1 >= num2) and (num1 >= num3):
big = num1
elif (num2 >= num1) and (num2 >= num3):
big = num2
else:
big = num3
print("The largest of three numbers is",big)
Output Enter first number: 12

Enter second number: 17

Enter third number: 25

The largest number is 25

Python Program to Display the multiplication Table

To displays the multiplication table of variable num (from 1 to 10).

# To take input from the user
number = int(input("Enter the number for multiplication table : "))
# Iterate 10 times from i = 1 to 10
fori in range(1, 11):
print(number, 'x', i, '=', number*i)
Output Enter the number for multiplication table: 2

2 x 1 = 2

2 x 2 = 24

2 x 3 = 36

2 x 4 = 48

2 x 5 = 60

2 x 6 = 72

2 x 7 = 84

2 x 8 = 96

2 x 9 = 108

2 x 10 = 120

Python Program to Check Armstrong Number

Armstrong number is a number equal to the sum of the cubes of its own digits. For example, 370 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3.

# Getinput from the user
num = int(input("Enter a number: "))
sum = 0
# Tofind the sum of the cube of each digit
tem = num
while tem> 0:
digit = tem % 10
sum += digit ** 3
tem //= 10
ifnum == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
Output

Enter a number: 370

370 is an Armstrong number

Python Program to Check Whether a Given String is Palindrome or Not

________________________________________A palindrome is a string that is the same when read forward and backward as well. For example: mom, madam,pop,radar

# Getting input from user
string=input(("Enter a string:"))
if(string==string[::-1]):
      print("The string is a palindrome")
else:
      print("Not a palindrome")
			
Output

The string is a palindrome.

Conclusion

These basic python programs helps to understand about how to write simple python programs, data types, operations and to learn, explore more.

Related Article

  • What is Python Programming?
  • Python 2 Vs Python 3
  • Why Learn Python Programming?

other top mnc Python Interview Q&A

  • TCS
  • Infosys
  • IBM
  • Capgemini
  • Cognizant
  • Wipro
  • HCL
  • DXC Technology
  • Contus
  • Fidelity
  • Tech Mahindra
  • L & T
  • FIS
  • Dell
  • Accenture

Python Latest News

Python Growth

According to a Forbes report on ‘technical skills with huge demand’, Python is listed top on the list, with a growth rate of 456% last year.

Python Annual Salary

The Average salary for Python Developer is 4, 42,713 per year in Indian based on 770 salaries submitted to Glassdoor by Python Developer employees.

CREDO SYSTEMZ – VELACHERY

New # 30, Old # 16A, Third Main Road,
Rajalakshmi Nagar, Velachery,
(Opp. to Murugan Kalyana Mandapam),
Chennai - 600 042.
Mobile: +91 9884412301
Email: info@credosystemz.com
Web: www.credosystemz.com

CREDO SYSTEMZ – OMR

Plot No.8, Vinayaga Avenue,
Rajiv Gandhi Salai, (OMR),
Okkiampettai,
Landmark - Okkiyampet Bus Stop,
Next to Buhari Hotel,
Chennai – 600 097.
Mobile: +91 9600112302

TRENDING COURSES

  • Data Science Training in Chennai
  • AWS Training in Chennai
  • Big Data Hadoop Training in Chennai
  • Machine Learning Training in Chennai
  • Angular Training in Chennai
  • Microsoft Azure Training
  • Mean Stack Training in Chennai
  • DevOps Training in Chennai
  • Oracle Primavera P6 Online Training
  • Spoken English Classes in Chennai

Copyright 2022 CREDO SYSTEMZ | All Rights Reserved.

BECOME AN INSTRUCTOR