Tag: Python lab programs
Python Program to Convert Celsius To Fahrenheit
In this python program, we will learn how to convert celsuis to farenheit in python and display it using the print function. This program takes the input in celsius degree and then converts it to farenheit degree. The farenheit is usually calculated using the below formula farenheit = (celsius * 1.8) + 32 How to convert Celsius to Fahrenheit in Python? Output 34.0 Celsius =…
Python Program to Find the Largest Value Among Three Numbers
This Python program shows you how you can use the conditional if else statement in Python to find the largest among three numbers and display the result. How to Find the Largest Value among three numbers in Python? Output The largest number among 3 Numbers is 65. In the above python program, the input numbers are stored in the variables number1,number2,number3 respectively. The conditional if…
Python Program to Calculate the Area of Triangle
This Python program shows how you can calculate the area of a triangle in python and display it using the python’s print method. How to Calculate the area if a triangle in Python? Assume that you have three variables side1,side2 and side3 which refers to the three sides of a triangle. The area of the triangle is calculated with the formula as shown below. area…
Python Program to Convert Kilometers to Miles
This program demonstrates how you can convert kilometers to miles in Python. The conversion of Kilometer to miles is a kind of a simple calculation. The formula to calculate the mile from kilometers is below. 1 Mile = 1.60934 Kilometers. All that we need to do is do multiple the input (kilometers) by 0.621371 to get the total miles. How to Convert Kilometers to Miles…
Python Program to Add Two Numbers
This Python program demonstrates how you can add two numbers in python and display it using the print() function. Python Program to Add Two Numbers Python program to add two numbers Output The sum of 898.2 and 111.6 is 1009.8000000000001 In this program , the variables number1 and number2 contains the numeric values that needs to be added. These two variable values are added and…
Python Program to Check Prime Number
This Python program demonstrates how you can check if a given number is a prime number or not. A number is a prime number if the following confitions are satisfied It is a Positive Number It is Greater than 1. Has no other factors except 1 and the number itself. Some of the examples of a prime number are 2,3 etc. How to Check if…
Python Program to Print Prime Numbers in a Given Interval
This Python program explains how you can print prime numbers in a given interval in python using loops. A number is a prime number if the following conditions are satisfied It is a Positive Number It is Greater than 1. Has no other factors except 1 and the number itself. Some of the examples of a prime number are 2,3 etc. How to Print Prime…
Python Program to Display Hello world
This is a simple program written in Python language that displays Hello World. The programs demonstrates how the Python code looks like and is a beginner program. Python Program to Display Hello world Output This program uses the python’s built-in print function to display the string Hello, world in the screen. The strings in python are by default in either single quotes , double quotes…
Python Program to Swap Two Variables
In this Python program , you will learn how to swap two variables easily with 2 options. Swap two variable using a temporary variable in python. Swap two variable without using temporary variable in python. How to Swap two variables in Python without using Temporary Variable? Output a : 3b : 8 How to Swap Two variables without using Temporary variable in Python? There are…
Python Program to Find the Square Root of Number
This python program will demonstrate how you can find the square root of a number using exponent operator python. Basic Program to find Square Root for Positive Number in Python Output The square root of 4.000 is 2.000 In this python program , we use the exponent operator ** to find the square root of the given positive number.
Python Program to Generate Multiplication Table
In this Python program, you will learn how to use loops in python to generate and display multiplication table of a given number. How to Generate and Display Multiplication Table in Python? Output 8 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 =…
Python Program to Check if a Number is Positive, Negative or Zero
In this python program, you’l learn how to check for a number of it is a positive , negative or zero. We will be using the conditional statements in python to solve this problem. How to find if a number is positive, negative or zero? Output The number that you entered is a Positive number A number is considered to be positive if it is…
Python Program to Generate Random Number
This program demonstrates how to generate random number in python using the randint method. How to generate random number in Python? Inorder to generate random number in Python, you will need to use the randint() function which is defined in the random module() in python. Output 7 Everytime when the randint function is called , it generates a different output as it is printed.
Python Program to Print Fibonacci Series
In this Python program, you will learn how to generate and print Fibonacci series using loops and conditional statements. What is a Fibonacci Sequence ? A Fibonacci sequence is an sequence of integers where the value of the sequence is determined by adding the preceding two values. The first two values in the sequence is 0 and 1. Then comes Next one with (N-1) +…