Python Programming

Advanced Python Training in Ranchi for Professionals

Advanced Python Training in Ranchi for Professionals

Advanced Python Training in Ranchi for Professionals Emancipation Edutech Pvt Ltd, Plaza Chowk — Your Launchpad to High-End Python Skills In today’s competitive tech industry, just knowing the basics of Python isn’t enough. Professionals seeking roles in data science, AI/ML, backend systems, automation, or full-stack engineering need advanced skills, real-world experience, and an up-to-date toolkit. For professionals in Ranchi, Emancipation Edutech Pvt Ltd at Plaza Chowk offers a training center finely tuned to meet those needs. Why Advanced Python Skills are in Demand What Makes Emancipation Edutech a Strong Option for Professionals From what’s available publicly, Emancipation Edutech offers several features especially beneficial for professionals wanting advanced training. Emancipation+4Emancipation+4EEPL+4 What Professionals Can Learn: Key Topics & Skills Here are some of the advanced topics/skills professionals should focus on, which Emancipation Edutech likely covers or could help with: Who Will Benefit Most After completing an advanced Python program, certain professionals will see significant gains. These include: Expected Outcomes & Career Impact What kind of outcomes you can expect after undergoing advanced Python training at a quality institute like Emancipation: Tips for Getting the Most Out of Advanced Training To maximize what you get from the course: Why Choose Ranchi & Emancipation Edutech For professionals located in Ranchi or nearby, there are advantages: Conclusion Advanced Python training is no longer optional for professionals aiming for high-impact tech roles. Whether your goal is to transition into data science, AI, backend engineering, DevOps, or build scalable applications, deepening your Python skills is essential. Emancipation Edutech Pvt Ltd in Ranchi, particularly at Plaza Chowk / Tharpakhna areas, offers a curriculum and support system well suited for professionals. With hands-on labs, flexible batches, project work, and career support, it can serve as a strong stepping stone. If you are a professional looking to upskill, this could be your opportunity. Do your homework: talk to alumni, review the syllabus, ensure the advanced topics you care about are covered, and commit to practice. The investment in skill now can pay off significantly in career growth, opportunities, and job satisfaction.

Advanced Python Training in Ranchi for Professionals Read More »

Career Scope of Python Developers in Ranchi

Career Scope of Python Developers in Ranchi

Career Scope of Python Developers in Ranchi (With insights from Emancipation Edutech Pvt Ltd, Plaza Chowk, Ranchi) In today’s tech-driven world, Python has become one of the most sought-after programming languages in India—and Ranchi is no exception. For students, fresh graduates, and working professionals looking to upskill, becoming a Python developer represents a promising pathway. Institutions like Emancipation Edutech Pvt Ltd, located at Plaza Chowk, Ranchi, are playing a key role in preparing learners to seize these opportunities. Here’s a look at what the career scope looks like, what employers are seeking, and how you can make the most of it. Why Python? What Makes It So Popular The Local Picture: Ranchi Types of Roles & Career Paths When you learn Python well (with the right frameworks, tools, and real-world exposure), these are some of the roles you can aim for: Role What You’ll Do Skills / Tools You’ll Need Junior / Entry Python Developer Build & maintain backend services; write scripts; simple automation; bug fixing Core Python, version control (Git), basic SQL/NoSQL Web Developer / Full-Stack Developer Backend APIs, web interfaces, integrating frontend & backend Django or Flask; HTML/CSS/JavaScript; REST APIs Data Analyst Cleaning, visualizing data, producing reports to guide business decisions Pandas, NumPy; data visualization tools; some SQL Data Scientist / ML Engineer Modeling, working with datasets; deploying ML models; predictive analytics Scikit-learn, TensorFlow or PyTorch; statistics; data wrangling Automation / Scripting / DevOps Adjacent Roles Automate workflows; build continuous integration pipelines; help with deployment Python scripting; APIs; familiarity with DevOps tools; basic cloud knowledge Freelance / Open Source / Startup Roles Project based work; open source contributions; lean product builds Versatility; good problem-solving; ability to manage projects with fewer resources Salary Trends & Prospects in Ranchi How Emancipation Edutech Helps You Build This Career Emancipation Edutech Pvt Ltd, Plaza Chowk, is well positioned for students and professionals in Ranchi aiming to build a Python career. Some of their strengths: What You Should Do to Maximise Opportunity If you want to make the most of the Python career scope in Ranchi (or anywhere), consider the following: Conclusion For people in Ranchi, the future looks bright if you choose to become a Python developer. With demand rising across sectors like web development, data analytics, machine learning, automation, and more, there are many avenues to grow. While competition is increasing, those who put in effort — strong learning, practical projects, good mentors — can expect solid careers. Institutes such as Emancipation Edutech Pvt Ltd at Plaza Chowk are valuable stepping stones: they help bridge the gap between theory and practice, helping learners be job-ready. If you’re considering a career in Python, now is a good time. With the right plan and consistent work, you can carve out a successful role in this space, even starting from Ranchi.

Career Scope of Python Developers in Ranchi Read More »

job ready developer training

Job Ready Developer Training: How Emancipation Makes You Industry-Ready

In today’s competitive tech job market, students and freshers often find themselves lost—even after completing degrees or online courses. That’s because real-world jobs demand real-world skills. This is exactly what job ready developer training at Emancipation Edutech Pvt. Ltd. provides. At Emancipation, we don’t just teach you how to code—we train you to become a complete, confident, and job-ready developer. 🧑‍💻 What Is Job Ready Developer Training? Job ready developer training means preparing students with everything they need to get hired in a tech job. This includes: This isn’t just training—it’s a launchpad for your career. 📚 Emancipation’s Job Ready Curriculum Here’s a breakdown of what you’ll learn through our job ready developer training: 🔹 Programming Foundations 🔹 Web Development Mastery 🔹 AI, ML, and Data Science 🔹 Industry Tools You don’t just learn theory—you build real projects that you can showcase in interviews. 👨‍🏫 Mentorship, Support & Career Preparation Our job ready developer training includes complete guidance from start to finish: Our mentors are experienced developers who know what recruiters expect and guide you accordingly. 📈 Real Student Success Stories “I joined Emancipation with zero coding knowledge. After 3 months, I built my own web app and cleared my first tech interview. Their hands-on training really works!”— Nikita, Final Year BBA Student “The combination of Python + ML + Full Stack Development helped me land my first internship. The project-based approach and mentorship gave me full confidence.”— Ravi, 2nd Year BCA Student 🎯 Why Choose Emancipation for Job Ready Developer Training? ✅ Industry-focused curriculum✅ Project-based hands-on learning✅ Regular guidance & support✅ Affordable fee structure✅ Placement-ready confidence Whether you are in college, have just graduated, or are switching careers—Emancipation helps you become job-ready from day one. 💼 What Makes Emancipation’s Approach Unique? While many institutes offer tech courses, very few focus on what actually gets you hired. At Emancipation, we start by identifying the real gaps in a student’s learning journey—whether it’s lack of confidence, missing fundamentals, or no practical exposure. We take a personalized approach, ensuring every learner is guided based on their background, learning pace, and career goals. Our training programs are regularly updated based on industry trends so that students are always learning what’s relevant. You’re not just another student to us—you’re a future innovator, developer, or entrepreneur in the making. 🌍 Community & Networking At Emancipation, you don’t learn alone. You become part of a growing community of developers, coders, and creators who motivate each other. We host: These events help you build connections with peers and industry professionals—which is just as important as technical skills when you’re looking for a job. With these additions, the blog is now highly optimized for: ✅ SEO best practices✅ Readability & engagement✅ Conversion through CTA 📝 Final Words The world needs developers who can think, build, and deliver—not just memorize code. With Emancipation’s job ready developer training, you don’t just learn—you prepare to perform. So if you’re serious about getting your first tech job, start your journey with us today. 📌 Enroll Now – Get Trained. Get Hired. 📍 Location: Plaza Chowk, Ranchi📞 Call/WhatsApp: +91-9264477176🌐 Website: www.emancipation.co.in🖥️ Courses: Full Stack, Python, AI/ML, ADCA, DCA

Job Ready Developer Training: How Emancipation Makes You Industry-Ready Read More »

Iterative Programs (For, While, Nested Loop)

Iterative Programs (For, While, Nested Loop)

The next topic is the For Loop. The for loop in Python is used to iterate over a sequence (like a list, tuple, dictionary, set, or string) or other iterable objects. This loop allows us to execute a block of code multiple times based on the length of the sequence or specified range. Below are 10 programs that demonstrate different uses of the For Loop in Python. For Loop Programs 1. Print Numbers from 1 to 10 Description: This program uses a for loop to print numbers from 1 to 10. # Program to print numbers from 1 to 10 for i in range(1, 11): print(i) 2. Print Even Numbers within a Range Description: Prints even numbers between 1 and 20 using a for loop with a step of 2. # Program to print even numbers from 1 to 20 for i in range(2, 21, 2): print(i) 3. Calculate the Sum of First N Natural Numbers Description: This program calculates the sum of the first n natural numbers. # Program to calculate the sum of first n natural numbers n = int(input("Enter a number: ")) sum_n = 0 for i in range(1, n + 1): sum_n += i print("Sum of first", n, "natural numbers is:", sum_n) 4. Display Multiplication Table Description: Displays the multiplication table of a number entered by the user. # Program to display the multiplication table num = int(input("Enter a number: ")) for i in range(1, 11): print(f"{num} x {i} = {num * i}") 5. Print Each Character of a String Description: Iterates over each character of a string and prints it on a new line. # Program to print each character of a string text = input("Enter a string: ") for char in text: print(char) 6. Find the Factorial of a Number Description: Computes the factorial of a number using a for loop. # Program to find the factorial of a number num = int(input("Enter a number: ")) factorial = 1 for i in range(1, num + 1): factorial *= i print("Factorial of", num, "is:", factorial) 7. Calculate the Sum of Elements in a List Description: This program calculates the sum of elements in a list using a for loop. # Program to calculate the sum of elements in a list numbers = [10, 20, 30, 40, 50] sum_numbers = 0 for num in numbers: sum_numbers += num print("Sum of list elements:", sum_numbers) 8. Display Only Positive Numbers from a List Description: Filters and displays only the positive numbers from a list of integers. # Program to display only positive numbers from a list numbers = [-10, 15, -30, 45, 0, 50] for num in numbers: if num > 0: print(num) 9. Print Fibonacci Series up to N Terms Description: Generates the Fibonacci series up to n terms. # Program to print Fibonacci series up to n terms n_terms = int(input("Enter the number of terms: ")) a, b = 0, 1 for i in range(n_terms): print(a, end=" ") a, b = b, a + b 10. Count Vowels in a String Description: Counts and displays the number of vowels in a given string. # Program to count vowels in a string text = input("Enter a string: ") vowels = "aeiouAEIOU" count = 0 for char in text: if char in vowels: count += 1 print("Number of vowels:", count) Explanation Each For Loop program showcases different ways to use for loops to iterate over numbers, lists, and strings. The for loop structure is versatile and allows us to perform various operations based on the elements or indexes of the sequence, which makes it essential for performing repeated tasks. The next topic is the While Loop. The while loop in Python repeatedly executes a block of code as long as the condition specified is True. This loop is useful when the number of iterations is not known beforehand, and we want the loop to continue until a certain condition is met. Below are 10 programs that demonstrate different uses of the While Loop in Python. While Loop Programs 1. Print Numbers from 1 to 10 Description: This program uses a while loop to print numbers from 1 to 10. # Program to print numbers from 1 to 10 using while loop i = 1 while i <= 10: print(i) i += 1 2. Sum of Natural Numbers Description: Calculates the sum of first n natural numbers using a while loop. # Program to calculate the sum of first n natural numbers using while loop n = int(input("Enter a number: ")) sum_n = 0 i = 1 while i <= n: sum_n += i i += 1 print("Sum of first", n, "natural numbers is:", sum_n) 3. Print Even Numbers Between 1 and 20 Description: Prints even numbers between 1 and 20 using a while loop. # Program to print even numbers from 1 to 20 using while loop i = 2 while i <= 20: print(i) i += 2 4. Reverse a Number Description: Reverses a number entered by the user using a while loop. # Program to reverse a number using while loop num = int(input("Enter a number: ")) reverse = 0 while num > 0: digit = num % 10 reverse = reverse * 10 + digit num = num // 10 print("Reversed number:", reverse) 5. Count Down from 10 to 1 Description: A countdown from 10 to 1 using a while loop. # Program to count down from 10 to 1 using while loop i = 10 while i > 0: print(i) i -= 1 6. Print Multiplication Table of a Number Description: Prints the multiplication table of a number entered by the user. # Program to print multiplication table using while loop num = int(input("Enter a number: ")) i = 1 while i <= 10: print(f"{num} x {i} = {num * i}") i += 1 7. Check for Prime Number Description: This program checks whether a number is prime using a while loop. # Program to check if a number is prime using while

Iterative Programs (For, While, Nested Loop) Read More »

Lists, Tuples, Dictionaries, and Sets

Lists, Tuples, Dictionaries, and Sets

The next topic is Lists, Tuples, Dictionaries, and Sets in Python. These are the core data structures used to store collections of data in Python, and each has its own unique characteristics and use cases. We will explore each of these data structures, along with their operations, methods, and common use cases. Lists, Tuples, Dictionaries, and Sets 1. Lists in Python A list is an ordered, mutable collection of items. Lists are widely used to store sequences of data and can hold any type of data, including numbers, strings, and other objects. Example: Create a List and Perform Operations # Creating a list my_list = [1, 2, 3, 4, 5] print("Original List:", my_list) # Append an item to the list my_list.append(6) print("After appending 6:", my_list) # Insert an item at a specific position my_list.insert(2, 7) print("After inserting 7 at index 2:", my_list) # Remove an item from the list my_list.remove(3) print("After removing 3:", my_list) # Pop an item from the list (removes the last item) popped_item = my_list.pop() print("Popped item:", popped_item) print("List after pop:", my_list) # Accessing elements using indexing print("Element at index 2:", my_list[2]) 2. Tuples in Python A tuple is similar to a list, but it is immutable, meaning you cannot change its elements once it is created. Tuples are typically used to store related pieces of data. Example: Create a Tuple and Perform Operations # Creating a tuple my_tuple = (1, 2, 3, 4, 5) print("Original Tuple:", my_tuple) # Accessing elements using indexing print("Element at index 3:", my_tuple[3]) # Trying to modify a tuple (will cause an error) # my_tuple[2] = 6 # This will raise a TypeError 3. Dictionaries in Python A dictionary is an unordered collection of key-value pairs. Dictionaries are useful for storing data in the form of a map or a lookup table, where each key is associated with a specific value. Example: Create a Dictionary and Perform Operations # Creating a dictionary my_dict = {‘name’: ‘John’, ‘age’: 25, ‘city’: ‘New York’} print("Original Dictionary:", my_dict) # Accessing values using keys print("Value associated with key ‘name’:", my_dict[‘name’]) # Adding a new key-value pair my_dict[’email’] = ‘john@example.com’ print("After adding email:", my_dict) # Updating a value for a key my_dict[‘age’] = 26 print("After updating age:", my_dict) # Removing a key-value pair del my_dict[‘city’] print("After removing ‘city’:", my_dict) 4. Sets in Python A set is an unordered collection of unique elements. Sets are useful for removing duplicates from a collection and performing set operations like union, intersection, and difference. Example: Create a Set and Perform Operations # Creating a set my_set = {1, 2, 3, 4, 5} print("Original Set:", my_set) # Adding an element to the set my_set.add(6) print("After adding 6:", my_set) # Removing an element from the set my_set.remove(3) print("After removing 3:", my_set) # Set operations: union, intersection another_set = {4, 5, 6, 7} print("Union of sets:", my_set | another_set) print("Intersection of sets:", my_set & another_set) 5. List Operations List slicing: Extract parts of the list using slicing. List comprehension: A concise way to create lists. Example: List Slicing and Comprehension # List slicing my_list = [1, 2, 3, 4, 5] print("Sliced list (index 1 to 3):", my_list[1:4]) # List comprehension squared_list = [x ** 2 for x in my_list] print("Squared List using comprehension:", squared_list) 6. Tuple Operations Tuples are commonly used for returning multiple values from a function or for storing fixed data. Example: Unpacking Tuple Values # Tuple unpacking my_tuple = (1, 2, 3) a, b, c = my_tuple print("Unpacked values:", a, b, c) 7. Dictionary Operations Dictionaries are very versatile and allow you to map values to keys. Example: Dictionary Operations # Check if a key exists if ‘name’ in my_dict: print("Key ‘name’ exists.") # Getting a value with a default if key does not exist print("Value for key ’email’:", my_dict.get(’email’, ‘Not Found’)) 8. Set Operations Sets support mathematical set operations, such as union, intersection, and difference, which are useful in many scenarios like removing duplicates and finding common or unique elements. Example: Set Operations # Union and intersection set1 = {1, 2, 3} set2 = {3, 4, 5} print("Union of set1 and set2:", set1 | set2) print("Intersection of set1 and set2:", set1 & set2) 9. Nested Lists, Tuples, Dictionaries, and Sets These data structures can be nested, meaning you can store one inside another. For example, you can have a list of tuples, or a dictionary of lists. Example: Nested Data Structures # List of tuples list_of_tuples = [(1, ‘apple’), (2, ‘banana’), (3, ‘cherry’)] print("List of tuples:", list_of_tuples) # Dictionary with lists as values dict_with_lists = {‘fruits’: [‘apple’, ‘banana’, ‘cherry’], ‘vegetables’: [‘carrot’, ‘potato’]} print("Dictionary with lists:", dict_with_lists) # Set of tuples set_of_tuples = {(1, ‘apple’), (2, ‘banana’)} print("Set of tuples:", set_of_tuples) Explanation Lists are versatile and mutable collections used to store ordered data. Tuples are immutable sequences, useful for fixed collections of items. Dictionaries allow you to store data in key-value pairs, providing efficient lookups by key. Sets are collections of unique items and are used for mathematical set operations, ensuring no duplicate elements. Let me know if you’d like to dive deeper into any of these data structures or move on to the next topic!

Lists, Tuples, Dictionaries, and Sets Read More »

Nested Functions

Nested Functions

Programs for Nested Functions Program 1: Basic Nested Function for Greeting def greet(name): """Outer function that defines a nested greeting function.""" def display_message(): """Inner function to create a greeting message.""" return f"Hello, {name}!" return display_message() # Example usage print(greet("Alice")) Expected Output: Hello, Alice! Program 2: Nested Function for Calculating Factorial def calculate_factorial(n): """Outer function to calculate factorial using an inner recursive function.""" def factorial(x): if x == 1: return 1 else: return x * factorial(x – 1) return factorial(n) # Example usage print("Factorial of 5:", calculate_factorial(5)) Expected Output: Factorial of 5: 120 Program 3: Nested Function to Calculate Area and Perimeter of a Rectangle def rectangle_properties(length, width): """Outer function to calculate area and perimeter using nested functions.""" def area(): return length * width def perimeter(): return 2 * (length + width) return f"Area: {area()}, Perimeter: {perimeter()}" # Example usage print(rectangle_properties(5, 3)) Expected Output: Area: 15, Perimeter: 16 Program 4: Nested Function to Find Maximum of Three Numbers def find_maximum(a, b, c): """Outer function to find the maximum of three numbers using a nested function.""" def maximum(x, y): return x if x > y else y return maximum(a, maximum(b, c)) # Example usage print("Maximum of 3, 7, and 5:", find_maximum(3, 7, 5)) Expected Output: Maximum of 3, 7, and 5: 7 Program 5: Nested Function with Conditional Logic (Palindrome Checker) def is_palindrome(word): """Outer function to check if a word is a palindrome.""" def reverse(w): return w[::-1] return word == reverse(word) # Example usage print("Is ‘radar’ a palindrome?", is_palindrome("radar")) print("Is ‘hello’ a palindrome?", is_palindrome("hello")) Expected Output: Is ‘radar’ a palindrome? True Is ‘hello’ a palindrome? False These examples demonstrate various uses of nested functions, from recursive calculations to helper functions for performing specific tasks within a larger function.

Nested Functions Read More »

Applications of Lambda Functions

Applications of Lambda Functions

Applications of Lambda Functions – Programs Program 1: Sorting a List of Tuples Based on the Second Element # List of tuples data = [(1, ‘apple’), (3, ‘banana’), (2, ‘cherry’), (4, ‘date’)] # Sort based on the second element in each tuple sorted_data = sorted(data, key=lambda x: x[1]) print("Sorted by second element:", sorted_data) Expected Output: Sorted by second element: [(1, ‘apple’), (3, ‘banana’), (2, ‘cherry’), (4, ‘date’)] Program 2: Using Lambda with map to Calculate Squares of a List of Numbers # List of numbers numbers = [1, 2, 3, 4, 5] # Apply lambda with map to square each number squared_numbers = list(map(lambda x: x ** 2, numbers)) print("Squared Numbers:", squared_numbers) Expected Output: Squared Numbers: [1, 4, 9, 16, 25] Program 3: Using Lambda with filter to Get Names Longer Than 5 Characters # List of names names = ["Alice", "Bob", "Charlie", "David", "Edward"] # Filter names longer than 5 characters long_names = list(filter(lambda name: len(name) > 5, names)) print("Names longer than 5 characters:", long_names) Expected Output: Names longer than 5 characters: [‘Charlie’, ‘Edward’] Program 4: Using Lambda with reduce to Calculate Product of List Elements from functools import reduce # List of numbers numbers = [1, 2, 3, 4, 5] # Reduce to calculate the product of all elements product = reduce(lambda x, y: x * y, numbers) print("Product of all elements:", product) Expected Output: Product of all elements: 120 Program 5: Lambda Function to Find the Maximum of Two Numbers # Lambda to find the maximum of two numbers max_value = lambda x, y: x if x > y else y # Example usage print("Max of 10 and 20:", max_value(10, 20)) Expected Output: Max of 10 and 20: 20

Applications of Lambda Functions Read More »

Implementation of Lambda Function within a Function

Implementation of Lambda Function within a Function

Programs for Lambda Functions within Functions Program 1: Function with a Lambda Expression for Customizable Mathematical Operations def math_operation(x, y, operation): """Perform a mathematical operation on two numbers using a lambda function.""" return operation(x, y) # Example usage add = lambda x, y: x + y subtract = lambda x, y: x – y print("Addition Result:", math_operation(5, 3, add)) print("Subtraction Result:", math_operation(5, 3, subtract)) Expected Output: Addition Result: 8 Subtraction Result: 2 Program 2: Function to Apply a Discount Using a Lambda Expression def apply_discount(price, discount): """Applies a discount using a lambda expression.""" calculate_discount = lambda p, d: p * (1 – d / 100) return calculate_discount(price, discount) # Example usage print("Price after 10% discount:", apply_discount(200, 10)) print("Price after 20% discount:", apply_discount(300, 20)) Expected Output: Price after 10% discount: 180.0 Price after 20% discount: 240.0 Program 3: Function to Return a Customized Greeting Using a Lambda def personalized_greeting(name, greeting): """Generates a personalized greeting.""" return greeting(name) # Lambda function for the greeting hello = lambda name: f"Hello, {name}!" good_morning = lambda name: f"Good morning, {name}!" # Example usage print(personalized_greeting("Alice", hello)) print(personalized_greeting("Bob", good_morning)) Expected Output: Hello, Alice! Good morning, Bob! Program 4: Function That Generates Power Functions Using Lambda def power_function(n): """Returns a lambda function to raise a number to the power of n.""" return lambda x: x ** n # Example usage square = power_function(2) cube = power_function(3) print("Square of 4:", square(4)) print("Cube of 3:", cube(3)) Expected Output: Square of 4: 16 Cube of 3: 27 Program 5: Lambda Function for Conditional Text Transformation def text_transformer(text, transform_type): """Applies a text transformation based on the provided lambda function.""" transformations = { "uppercase": lambda x: x.upper(), "lowercase": lambda x: x.lower(), "titlecase": lambda x: x.title() } return transformations[transform_type](text) # Example usage print(text_transformer("Hello World", "uppercase")) print(text_transformer("Hello World", "lowercase")) print(text_transformer("hello world", "titlecase")) Expected Output: HELLO WORLD hello world Hello World These examples demonstrate how lambda functions can be incorporated within other functions for dynamic and customized behavior. Let me know if you’d like to proceed with the next topic!

Implementation of Lambda Function within a Function Read More »

Lambda Functions - Programs

Lambda Functions – Programs

Lambda Functions – Programs Program 1: Simple Lambda Function for Addition # Lambda function for adding two numbers add = lambda x, y: x + y # Example usage result = add(5, 3) print("Addition Result:", result) Expected Output: Addition Result: 8 Program 2: Lambda Function for Multiplication # Lambda function for multiplying two numbers multiply = lambda x, y: x * y # Example usage result = multiply(4, 7) print("Multiplication Result:", result) Expected Output: Multiplication Result: 28 Program 3: Lambda Function with Conditional Logic (Even or Odd Check) # Lambda function to check if a number is even or odd check_even_odd = lambda x: "Even" if x % 2 == 0 else "Odd" # Example usage print("10 is:", check_even_odd(10)) print("15 is:", check_even_odd(15)) Expected Output: 10 is: Even 15 is: Odd Program 4: Lambda Function for Calculating Square of a Number # Lambda function for squaring a number square = lambda x: x ** 2 # Example usage print("Square of 6:", square(6)) Expected Output: Square of 6: 36 Program 5: Lambda Function for Filtering Even Numbers from a List # List of numbers numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # Using lambda function with filter to get even numbers even_numbers = list(filter(lambda x: x % 2 == 0, numbers)) print("Even Numbers:", even_numbers) Expected Output: Even Numbers: [2, 4, 6, 8, 10]

Lambda Functions – Programs Read More »

Creating Your Own Module

Creating Your Own Module

Programs for Creating and Using a Custom Module Step 1: Create a Custom Module (mymodule.py) Create a file named mymodule.py with the following functions. # mymodule.py def add(a, b): """Returns the sum of two numbers.""" return a + b def subtract(a, b): """Returns the difference between two numbers.""" return a – b def multiply(a, b): """Returns the product of two numbers.""" return a * b def divide(a, b): """Returns the quotient of two numbers, if b is not zero.""" if b != 0: return a / b else: return "Cannot divide by zero" def factorial(n): """Returns the factorial of a number.""" if n == 0: return 1 else: return n * factorial(n – 1) def greet(name): """Returns a greeting message.""" return f"Hello, {name}!" Save this code as mymodule.py. We’ll now import and use it in different programs. Program 1: Import and Use the add and subtract Functions import mymodule # Using the add function result_add = mymodule.add(5, 3) print("Addition Result:", result_add) # Using the subtract function result_subtract = mymodule.subtract(10, 4) print("Subtraction Result:", result_subtract) Expected Output: Addition Result: 8 Subtraction Result: 6 Program 2: Import and Use the multiply and divide Functions import mymodule # Using the multiply function result_multiply = mymodule.multiply(7, 6) print("Multiplication Result:", result_multiply) # Using the divide function result_divide = mymodule.divide(42, 7) print("Division Result:", result_divide) Expected Output: Multiplication Result: 42 Division Result: 6.0 Program 3: Use the factorial Function import mymodule # Using the factorial function num = 5 result_factorial = mymodule.factorial(num) print(f"Factorial of {num}:", result_factorial) Expected Output: Factorial of 5: 120 Program 4: Use the greet Function import mymodule # Using the greet function name = "Alice" greeting = mymodule.greet(name) print(greeting) Expected Output: Hello, Alice! Program 5: Use All Functions Together in a Comprehensive Program import mymodule # Calling all functions print("Addition:", mymodule.add(10, 5)) print("Subtraction:", mymodule.subtract(10, 5)) print("Multiplication:", mymodule.multiply(10, 5)) print("Division:", mymodule.divide(10, 5)) print("Factorial of 4:", mymodule.factorial(4)) print("Greeting:", mymodule.greet("Charlie")) Expected Output: Addition: 15 Subtraction: 5 Multiplication: 50 Division: 2.0 Factorial of 4: 24 Greeting: Hello, Charlie! Program 6: Import Specific Functions Directly from mymodule import add, greet # Directly calling add and greet without prefix print("Addition:", add(3, 9)) print(greet("Bob")) Expected Output: Addition: 12 Hello, Bob! Program 7: Use Aliases for Functions import mymodule as mm # Calling functions with module alias print("Multiplication (Alias):", mm.multiply(4, 7)) print("Division (Alias):", mm.divide(35, 5)) Expected Output: Multiplication (Alias): 28 Division (Alias): 7.0 Program 8: Use factorial with Larger Input import mymodule # Calculating factorial of a larger number print("Factorial of 7:", mymodule.factorial(7)) Expected Output: Factorial of 7: 5040 Program 9: Error Handling with divide import mymodule # Attempt division by zero result = mymodule.divide(5, 0) print("Division Result:", result) Expected Output: Division Result: Cannot divide by zero Program 10: Conditional Import and Use try: import mymodule # Only execute if the module is present print("Factorial of 3:", mymodule.factorial(3)) except ImportError: print("Module ‘mymodule’ not found.") Expected Output (if module is present): Factorial of 3: 6 These programs demonstrate using a custom module, with expected outputs provided for each example.

Creating Your Own Module Read More »

Scroll to Top
Contact Form Demo