Category: Other

python tutorials and learn python

Created with Sketch.

Python program that checks if a given number is odd or even:

Python program that checks if a given number is odd or even: The program prompts the user to enter a number using the input() function, and stores the value in the variable “number”. It then uses an if-else statement to check if the remainder of dividing the number by 2 is equal to 0. If…
Read more

Python program that checks if a given number is positive, negative, or zero:

Python program that checks if a given number is positive, negative, or zero: The program prompts the user to enter a number using the input() function, and stores the value in the variable “number”. It then uses an if-elif-else statement to check the value of the number. If the number is greater than 0, it…
Read more

Python program that displays a calendar for a given month and year:

Python program that displays a calendar for a given month and year: The program prompts the user to enter the year and month using the input() function, and stores the values in the variables “year” and “month”. It then imports the calendar module and uses the month() function to display the calendar for the given…
Read more

Python program that converts Celsius to Fahrenheit:

Python program that converts Celsius to Fahrenheit: The program prompts the user to enter the temperature in Celsius using the input() function, and stores the value in the variable “celsius”. It then uses the formula (celsius * 9/5) + 32 to convert Celsius to Fahrenheit. And then it prints the result using the print() function.…
Read more

Python program that generates a random number between a given range

Python program that generates a random number between a given range The program imports the random module and then uses the randint() function to generate a random integer between 1 and 100 (inclusive) and print it. You can also generate a random number between a given range by using the random() function from the random…
Read more

Python program that swaps the values of two variables:

Here is a Python program that swaps the values of two variables: The program uses a temporary variable, “temp” to store the value of x, then assigns the value of y to x, and finally assigns the value of temp (original value of x) to y. Another way to swap two variables is by using…
Read more

Here is a Python program that solves a quadratic equation of the form ax^2 + bx + c = 0:

Here is a Python program that solves a quadratic equation of the form ax^2 + bx + c = 0: The program prompts the user to enter the coefficients of the quadratic equation using the input() function, and stores them in variables a, b, and c. It then calculates the discriminant (d) using the formula…
Read more

Here is a Python program that calculates the area of a triangle given the base and height:

Here is a Python program that calculates the area of a triangle given the base and height: The program uses the formula for the area of a triangle (base * height / 2) to calculate the area. It prompts the user to enter the base and height of the triangle using the input() function and…
Read more

Here is an example of a Python program that performs basic arithmetic operations:

Here is an example of a Python program that performs basic arithmetic operations: The program uses the basic mathematical operators for addition (+), subtraction (-), multiplication (*), division (/), floor division (//), modulus (%), and exponentiation (**) to perform the corresponding arithmetic operations. You can run this program by saving it in a file with…
Read more

Python Range Data Type (PYTHON FUNDAMENTALS)

Python Range Data Type  range Data Type represents a sequence of numbers.  The elements present in the range Data type are not modifiable. i.e range Data type is immutable. Form-1: range(10)generate numbers from 0 to 9 Eg: r = range(10)for i in r : print(i) —> 0 to 9 Form-2: range(10, 20)generate numbers from 10…
Read more