Category: Python
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 =…
Recursive Functions in Python
This tutorial will teach you about Python recursive functions and how to use them to simplify your code. A recursive function is one that calls itself until it stops. The fn() function below is a recursive function because it calls itself: The #… in the fn() function denotes other code. A recursive function must also have a condition that causes it to stop calling itself….
Python Program to Check if a Number is Odd or Even
In this Python program, let’s learn how you can check a given number if it is odd or even. How to Check if a Number is Odd or Even in Python? A number is a even number if it is perfectly divisible by 2 i.e if the remainder is 0. In Python, you can use the modulus operator (%) to find the remainder. If the…
Python Program to add two integers
Problem Write a program in Python to add two integers and display the result on the screen. Python Program to add two integers Output Enter first number: 1 Enter second number: 2 1 + 2 = 3.0
Comments in Python
This tutorial will teach you how to add comments to your code. You’ll also learn about different types of Python comments, such as block comments, inline comments, and documentation strings. You may want to document the code you write on occasion. You might wish to take note of why a piece of code works, for example. You use the comments to accomplish this. Formulas, algorithms,…
Functions in Python
In this tutorial, you will learn how to create Python functions using the def keyword. What is Function in Python? A named code block that performs a task or returns a value is referred to as a function. In some programs, you may need to repeat a task numerous times. You also don’t want to duplicate the code for the same task in several places….
Getting Started with Python
This tutorial will teach you what Python is and why you should start learning Python right away. Python is a cross-platform programming language, meaning it can operate on a variety of platforms including Windows, macOS, Linux, and the Java and.NET virtual machines. It’s completely free and open-source. Python boosts your efficiency. Python allows you to solve complicated issues with fewer lines of code and less…
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 Find the Factorial of a Number
In this Python program, you will learn how to find the factorial of a number and display it using the print statement. Before we start coding, its important to understand what is a factorial. The factorial of a number is the product io all the number from 1 until that number. To give you an example , lets say you want to find the factorial…
Constants in Python
This tutorial will teach you how to define Python constants. Variables are useful for storing values. However, these values should not be changed during the program’s execution. You can use constants to accomplish this in different programming languages. Constants are similar to variables, except that their values do not change as the programme runs. Constants aren’t supported in Python, which is unfortunate. To get around…
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…
Sort List in Python
In this article, you’ll learn how to sort a list with Python’s List sort() method. The sort() method is used to sort a list: The sort() method keeps the order of the original list. The sort() method changes the order of the elements in the list. The less-than operator () is used by default in the sort() method to sort the members of a list….