Easy
  Python
    Guide
Input Statements
Input statements in Python are fundamental tools that allow programs to interact with users by requesting and receiving information during program execution. The most common input statement is the input() function, which pauses program execution and waits for the user to type something and press Enter. When a user provides input, Python treats it as text (a string) by default, though it can be converted to other data types when needed. This interactive capability transforms static programs into dynamic applications that can respond to user needs and preferences.
The basic syntax of Python's input function is straightforward: user_input = input("Enter your name: "). The text inside the brackets serves as a prompt that appears on screen, guiding users about what information to provide. For example, age = int(input("How old are you? ")) not only requests input but also converts the response to an integer for mathematical operations. This conversion is crucial because input always returns strings, so functions like int(), float(), or bool() are often needed to work with the data appropriately.
In customer service roles, input statements are extensively used in help desk applications and automated support systems. Customer service representatives might use Python scripts that prompt for customer details like account numbers, complaint categories, or contact preferences. For instance, a support ticket system might use ticket_type = input("Is this a billing, technical, or general enquiry? ") to categorise issues automatically. Similarly, data entry clerks use input-driven programs to efficiently process information, where prompts guide them through standardised data collection procedures, ensuring consistency and reducing errors.
Software developers and web developers frequently employ input statements during development and testing phases. They create scripts that prompt for configuration settings, database credentials, or testing parameters. A developer might write database_name = input("Enter database name for testing: ") to make their testing scripts flexible across different environments. In web development, input statements are crucial for creating command-line tools that generate project templates, configure deployment settings, or manage user permissions. These tools streamline repetitive tasks and allow developers to customise their workflow efficiently.
Business analysts and data scientists rely heavily on input statements to create interactive data analysis tools and reporting systems. They might develop scripts that prompt managers for date ranges, department codes, or specific metrics to generate tailored reports. For example, start_date = input("Enter start date (DD/MM/YYYY): ") allows users to specify timeframes for sales analysis or performance reviews. Similarly, inventory managers use input-driven programs to update stock levels, process orders, or generate purchase recommendations, where prompts guide them through systematic data collection that feeds into larger business intelligence systems.
Syntax:
Some examples of how input statements are used:
# Example 1: Customer Service Help Desk System
print("=== CUSTOMER SUPPORT TICKET SYSTEM ===")
customer_name = input("Enter customer name: ")
account_number = input("Enter account number: ")
issue_type = input("Issue type (billing/technical/general): ")
priority = input("Priority level (low/medium/high): ")
description = input("Brief description of issue: ")
print(f"\nTicket created for {customer_name}")
print(f"Account: {account_number} | Type: {issue_type} | Priority: {priority}")
print(f"Description: {description}")
print("\n" + "="*50 + "\n")
# Example 2: Retail Point of Sale System
print("=== RETAIL CHECKOUT SYSTEM ===")
item_name = input("Enter item name: ")
quantity = int(input("Enter quantity: "))
price_per_item = float(input("Enter price per item (£): "))
discount_percent = float(input("Enter discount percentage (0 if none): "))
total_before_discount = quantity * price_per_item
discount_amount = total_before_discount * (discount_percent / 100)
final_total = total_before_discount - discount_amount
print(f"\nItem: {item_name}")
print(f"Quantity: {quantity} x £{price_per_item:.2f}")
print(f"Subtotal: £{total_before_discount:.2f}")
print(f"Discount: £{discount_amount:.2f}")
print(f"Final Total: £{final_total:.2f}")
print("\n" + "="*50 + "\n")
# Example 3: Employee Database Management
print("=== EMPLOYEE REGISTRATION SYSTEM ===")
employee_id = input("Enter employee ID: ")
full_name = input("Enter full name: ")
department = input("Enter department: ")
position = input("Enter job position: ")
start_date = input("Enter start date (DD/MM/YYYY): ")
salary = float(input("Enter annual salary (£): "))
print(f"\nEmployee Profile Created:")
print(f"ID: {employee_id}")
print(f"Name: {full_name}")
print(f"Department: {department}")
print(f"Position: {position}")
print(f"Start Date: {start_date}")
print(f"Salary: £{salary:,.2f}")
print("\n" + "="*50 + "\n")
# Example 4: Medical Patient Registration
print("=== PATIENT REGISTRATION SYSTEM ===")
patient_name = input("Enter patient name: ")
date_of_birth = input("Enter date of birth (DD/MM/YYYY): ")
nhs_number = input("Enter NHS number: ")
contact_number = input("Enter contact number: ")
emergency_contact = input("Enter emergency contact name: ")
emergency_phone = input("Enter emergency contact phone: ")
allergies = input("Enter any allergies (or 'none'): ")
print(f"\nPatient Registration Complete:")
print(f"Patient: {patient_name}")
print(f"DOB: {date_of_birth}")
print(f"NHS: {nhs_number}")
print(f"Contact: {contact_number}")
print(f"Emergency Contact: {emergency_contact} ({emergency_phone})")
print(f"Allergies: {allergies}")
print("\n" + "="*50 + "\n")
# Example 5: Bank Account Transaction Processing
print("=== BANK TRANSACTION SYSTEM ===")
account_holder = input("Enter account holder name: ")
account_number = input("Enter account number: ")
transaction_type = input("Enter transaction type (deposit/withdrawal): ")
amount = float(input("Enter transaction amount (£): "))
current_balance = float(input("Enter current balance (£): "))
if transaction_type.lower() == "deposit":
new_balance = current_balance + amount
print(f"\nDeposit successful!")
elif transaction_type.lower() == "withdrawal":
if amount <= current_balance:
new_balance = current_balance - amount
print(f"\nWithdrawal successful!")
else:
new_balance = current_balance
print(f"\nWithdrawal declined - insufficient funds!")
else:
new_balance = current_balance
print(f"\nInvalid transaction type!")
print(f"Account Holder: {account_holder}")
print(f"Account Number: {account_number}")
print(f"Transaction: {transaction_type.title()} of £{amount:.2f}")
print(f"Previous Balance: £{current_balance:.2f}")
print(f"New Balance: £{new_balance:.2f}")