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 : " +...
Tag - Python Exercices for Beginners
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...
Calculate Area Of A Circle In Python
Write a Python program which accepts the radius of a circle from the user and compute the area. Solution 1: Python r = float(input("Enter radius of circle: ")) a = 3.14159 * r * r print("Area of circle =", a) 12345 r =...
Display the Current Date and Time in Python
In this example, i’ll show you how to display the current date and time in Python. Python Code: Python import datetime now = datetime.datetime.now() print ("Current date and time : ") print (now.strftime("%Y-%m-%d...
Calculate Factorial of a Number in Python
Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720. 1.Recursive : Python # Python 3 program to find # factorial of given...
How to Return a Value in Python- Calculate Rectangle Area
We will often need to return a value from a function. We can do this with the return statement in Python. We just need to write this in the function definition: return <value_to_return> 123 return...
Functions with Two or More Parameters in Python
In Python, we can define functions to make our code reusable, more readable, and organized. This is the basic syntax of a Python function: def <function_name>(<param1>, <param2>, ...): <code> 1234...
Function with One Parameter in Python
In Python, we can define functions to make our code reusable, more readable, and organized. This is the basic syntax of a Python function: def <function_name>(<param1>, <param2>, ...): <code> 1234...
Python Program to Convert Decimal Number to Binary
In this post, we will write a Python 3 program to convert decimal number to binary. Python Code:
Display All The Numbers Between 1 to N in Python
Python3 proram to Print all the numbers between 1 to N. Python Code: