# Create a function to check eligibility# for votingdefcheckEligibility(a):# condition to check voting eligibilityifage>=18:returnTrueelse:returnFalse# Main code# input ageage=int(input("Enter Age : "))# Call f
Eligibility for Aadhar Card - Nested if Statement age = int(input("Enter your age : ")) if age > 5: nationality = input("Enter your Nationality : ") if nationality.upper() == 'INDIAN' : print("You are eligible for Aadhar card") else: print("Not for other nationalities") else: ...
Explanation: Here, the function check_voting_eligibility(age) checks if the age of the voter is greater than or equal to 18 and prints the eligibility status. Working with If…Else Statements in Loops If-Else statements inside loops allow decision-making during each iteration, which helps to ...
Python | Input age and check eligibility for voting Python | Find largest of three number using nested if else Python | Calculate discount based on the sale amount Python | Calculate discount based on the sale amount using Nested if else Python | Design a simple calculator using if elif (jus...
# Code to find factorial on num# numbernum=4# 'fact' - variable to store factorialfact=1# run loop from 1 to num# multiply the numbers from 1 to num# and, assign it to fact variableforiinrange(1,num +1): fact=fact * i# print the factorialprint("Factorial of {0} is: {1} ...
Given a character, and we have to find its ASCII code using Python program. ASCII value of character in Python In Python, to get theASCIIvalue of a character, we useord() function. Theord()accepts a character and returns the ASCII value of it. ...
Here, we are going to implement a Python program that will print all numbers between 1 to 1000, which are divisible by 7 and must not be divisible by 5.
While writing the code, sometimes we need to print the space. For example, print space between the message and the values, print space between two values, etc. In the Python programming language, it's easy to print the space. Following are the examples demonstratinghow to print the spaces ...
Python code to find power of a number using loop num=int(input("Enter the number of which you have to find power: "))pw=int(input("Enter the power: "))kj=1forninrange(pw):kj=kj*numprint(kj) Output Enter the number of which you have to find power: 5 Enter the power: 4 625...
Python code forrowinrange(0,5):forcolumninrange(0,row+1):print("*",end="")# ending rowprint('\r') 2. Python Program for Half Pyramid of Ones (1) Now if we want to print numbers or alphabets in this pattern then we need to replace the*with the desired number you want to repl...