In this post, we will learn about the data type used in Python. Every programming language has this same concept as the data type. Similarly, Python has a data type of every variable that is used in the code. The datatype is very...
Tag - Python Tutorial Examples
Find Sum Of Elements In A List in Python
In this article, we will learn How to find sum of elements in a list in Python. In this article, we will show you how to find the sum of numbers of the list in Python language;. This programs take input from the user for the list...
Find the Greatest of Three Numbers Using the Function in Python
In this example, we will discuss the concept of the Python program:find the greatest of three numbers using the function In this post, we will learn how to find the greatest number of three numbers using a user-defined function...
Sort a Dictionary in Python
In this example, we will learn how to sort a dictionary in python. In the below example we will sort a dictionary by key, value, and items. Sort by key: Python dict = {} dict['1'] = 'Ford' dict['4'] = 'Audi' dict['2'] = 'Toyota'...
Filter the Positive Numbers from a list in Python
In this example, i’ll show you how to filter the positive numbers from a list. Python Code: Python nums = [-15, 12, 15, -5] print("Original numbers in the list: ",nums) Pos_nums = list(filter(lambda x: x >0, nums))...
Python Program to Check Whether a Number is Even or Odd
In this example, you will learn to check whether a number entered by the user is even or odd. In the program, the integer entered by the user is stored in the variable num. Then, whether num is perfectly divisible...
Calculate the Sum of Three Given Numbers
Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum. Python Code: Python def sum_thrice(x, y, z): sum = x + y + z if x == y == z: sum = sum * 3 return sum...
Print the Calendar of a Given Month and Year
In this example, i’ll show you how to print the calendar of a given month and year. Python Code: Python import calendar year = int(input("Input the year : ")) month = int(input("Input the month : ")) print(calendar...
Accept a filename from the user and print the extension of that file in Python
Write a Python program to accept a filename from the user and print the extension of that file. Python Code: Python filename = input("Input the Filename: ") f_extns = filename.split(".") print ("The extension of the file is : " +...
Reverse a String in Python
Write a Python program which accepts the user’s first and last name and print them in reverse order. Python Code: Python firstname = input("Input your First Name : ") lastname = input("Input your Last Name : ") print...