Tag: python tutorials

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…

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…

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….

Lambda Expressions in Python

This tutorial will teach you about Python lambda expressions and how to use them to write anonymous functions. Sometimes you’ll need to write a single-expression function. This function, however, must only be used once. It will also be obsolete to use the def keyword to declare that function. Python lambda expressions are useful in this situation. What are Lambdas in Python? Anonymous functions can be…

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…