Validate Work Age,: Account Withdrawal

UpComing SoftWare Training Demos

๐Ÿš€ *Gen AI Engineerย Telugu (Production Focused)*
๐Ÿ—“๏ธ *Date:* 30th Sept 2026, 07:00AM IST
๐Ÿ“ *Register Now!:*
https://www.vlrt.in/gr
๐Ÿ‘ฅ *Join WA Community:*
https://www.vlrt.in/gw
๐Ÿ’ก*Course Content:*
https://www.vlrt.in/ai
โ–ถ๏ธ *Demo Videos:*
https://www.vlrt.in/gv

๐Ÿš€ *Service now Admin/ Development (ITSM)FREE Demo in Telugu*
๐Ÿ—“๏ธ *Date:* 30th Sept 2026, 08:00AM IST
๐Ÿ“ *Register Now!:*
https://www.vlrt.in/7r
๐Ÿ‘ฅ *Join WA Community:*
https://www.vlrt.in/7w
๐Ÿ’ก*Course Content:*
https://www.vlrt.in/7c
โ–ถ๏ธ *Demo Videos:*
https://www.vlrt.in/7v

๐Ÿš€ *Vulnerability Management Training Demo*
๐Ÿ—“๏ธ *Date:* 30th Sept 2026, 09:00 AM IST
๐Ÿ“*Register Now!:*
https://www.vlrt.in/vr
๐Ÿ‘ฅ *Join Community:*
https://www.vlrt.in/cw
๐Ÿ’ก *Course Content:*
https://www.vlrt.in/vc
โ–ถ๏ธ *Demo Videos:*
https://www.vlrt.in/Vm

class InvalidAgeError(Exception):
    pass


def validate_age(age):
    if age >= 18 and age <=60:
        return True
    else:
        raise InvalidAgeError('Age should be between 18-60')


name = input('Enter Name:')
age = int(input('Enter Age:'))

try:
    validate_age(age)
    print('You can join Work')
except InvalidAgeError as e:
    print(e)

class InsufficientFundsError(Exception):
    pass

def withdraw(balance, amount):
    if amount > balance:
        raise InsufficientFundsError("Not enough funds")
    return balance - amount


balance = 5000
amount = int(input("Enter Amount: "))

try:
    balance = withdraw(balance, amount)
    print('Withdrawal successful')
    print('Remaining balance:', balance)
except InsufficientFundsError as e:
    print(e)

Similar Posts

  • what is pythonย 

    What is Python? Python is a popular, high-level programming language known for its simplicity and readability. Because its syntax closely resembles everyday English, it is incredibly easy for beginners to learn, read, and write. Despite being beginner-friendly, it is also one of the most powerful languages in the world, used heavily by professionals for artificial…

  • re Programs

    The regular expression r’;\s*(.*?);’ is used to find and extract text that is located between two semicolons. In summary, this expression finds a semicolon, then non-greedily captures all characters up to the next semicolon. This is an effective way to extract the middle value from a semicolon-separated string. Title 1 to 25 chars The regular…

  • Python Program to Check Pangram Phrases

    Python Program to Check Pangram Phrases What is a Pangram? A pangram is a sentence or phrase that contains every letter of the alphabet at least once. Method 1: Using Set Operations python def is_pangram_set(phrase): “”” Check if a phrase is a pangram using set operations “”” # Convert to lowercase and remove non-alphabetic characters…

  • Variable Length Positional Arguments in Python

    Variable Length Positional Arguments in Python Variable length positional arguments allow a function to accept any number of positional arguments. This is done using the *args syntax. Syntax python def function_name(*args): # function body # args becomes a tuple containing all positional arguments Simple Examples Example 1: Basic *args python def print_numbers(*args): print(“Numbers received:”, args) print(“Type of…

  • Date/Time Objects

    Creating and Manipulating Date/Time Objects in Python 1. Creating Date and Time Objects Creating Date Objects python from datetime import date, time, datetime # Create date objects date1 = date(2023, 12, 25) # Christmas 2023 date2 = date(2024, 1, 1) # New Year 2024 date3 = date(2023, 6, 15) # Random date print(“Date Objects:”) print(f”Christmas:…

  • Functions as Parameters in Python

    Functions as Parameters in Python In Python, functions are first-class objects, which means they can be: Basic Concept When we pass a function as a parameter, we’re essentially allowing one function to use another function’s behavior. Simple Examples Example 1: Basic Function as Parameter python def greet(name): return f”Hello, {name}!” def farewell(name): return f”Goodbye, {name}!” def…

Leave a Reply

Your email address will not be published. Required fields are marked *