Blog

python tutorials and learn python

Created with Sketch.

Python program that uses recursion to display the Fibonacci sequence up to a given number:

Python program that uses recursion to display the Fibonacci sequence up to a given number: The fibonacci() function takes a single argument, n, which represents the number of terms in the sequence to be displayed. The function uses recursion to calculate the terms of the Fibonacci sequence. The base case for the recursion is when…
Read more

Python program that uses the built-in calendar module to display a calendar for a given year:

python program that uses the built-in calendar module to display a calendar for a given year: The calendar.calendar() function takes a single argument, the year for which to display the calendar, and returns a string representation of the calendar for that year. The input() function is used to prompt the user to enter a year,…
Read more

Python program that makes a simple calculator:

Python program that makes a simple calculator: This program defines a function calculator() that takes an operator and two numbers as arguments. The function uses an if-elif statement to check the operator and perform the appropriate arithmetic operation on the two numbers and return the result. The program then prompts the user to enter two…
Read more

Python program that finds the ASCII value of a given character:

python program that finds the ASCII value of a given character: The program prompts the user to enter a character using the input() function, and stores the value in the variable “character”. It then uses the built-in function ord() to find the ASCII value of the character. The ord() function returns an integer representing the…
Read more

Python program that converts a given decimal number to binary, octal and hexadecimal:

Python program that converts a given decimal number to binary, octal and hexadecimal: The program prompts the user to enter a decimal number using the input() function, and stores the value in the variable “decimal”. Then it uses the built-in functions bin(), oct() and hex() to convert the decimal number to binary, octal and hexadecimal…
Read more

Python program that finds the highest common factor (HCF) of two given numbers:

Python program that finds the highest common factor (HCF) of two given numbers: The program prompts the user to enter two numbers using the input() function, and stores the values in the variables “num1” and “num2”. It then uses an if-else statement to find the smaller number out of the two numbers. Then it uses…
Read more

Python program that finds the least common multiple (LCM) of two given numbers:

Python program that finds the least common multiple (LCM) of two given numbers: The program prompts the user to enter two numbers using the input() function, and stores the values in the variables “num1” and “num2”. It then uses an if-else statement to find the maximum number out of the two numbers. Then it uses…
Read more

Python program that finds the sum of natural numbers up to a given number:

Python program that finds the sum of natural numbers up to a given number: 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 statement to check if the number is valid, which is a positive integer greater than…
Read more

Python program that finds all Armstrong numbers in a given range:

Python program that finds all Armstrong numbers in a given range: The program prompts the user to enter the start and end of the range using the input() function, and stores the values in the variables “start” and “end”. It then uses a for loop to iterate through the range of numbers between start and…
Read more

Python program that checks if a given number is an Armstrong number:

Python program that checks if a given number is an Armstrong number: The program prompts the user to enter a number using the input() function, and stores the value in the variable “number”. It then uses a while loop to check if the number is an Armstrong number. An Armstrong number is a number that…
Read more