Name: _____________________________________________________ ______________________________________________________ Batch: _______________ Roll no : ________ Department: __________________________________________ SHRI G.P.M.DEGREE COLLEGE MahatmaGandhiRd,VileParleEast,Mumbai-400057, Tel.:8928387200. CERTIFICATE This is to certify that Mr/Ms _____________________________________ a student of F.Y.B.Sc. Roll No. _______ has completed the required number of practical in the subject of ___________________________________ as prescribed by the UNIVERSITY OF MUMBAI under my super vision during the academic year 2025-2026. Signatories: Subject In-charge (Name &Sign) : _________________ Principal Sign (Name & Sign) :_ ____________________ External Examiner (Name &Sign) : _________________ Date: ___________ ____________ College Stamp INDEX Teacher name: Mrs.Himani Saxena Subject :- IT Fundamentals of Python Programming Class/SEM : F.Y.BSC.CS/SEM-II(2025-26) Coursecode : Major 1 Sr. No. DATE Experiment Title Page No. Signature 1 Basic Python Programs Aim: a) “Hello World”. b) add two numbers . c) square root . d) area of a triangle. 2 Conditional execution Aim: a). Write a Python Program to Check Leap Year. b. Write a Python Program to Find the Largest Among Three Numbers c. Write a Python Program to Check Prime Numbers. d.) Write a Python Program to Find the Factorial of a Number. e. Write a Python Program to convert kilometers to miles 3 String Aim: a.) Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. b). Define a function that computes the length of a given list or string. c.) Python program to check whether the string is Symmetrical or Palindrome. d). Write a Python Program to Reverse words in a given String. e). A pangram is a sentence that contains all the letters of the English alphabet at least once, for example: The quick brown fox jumps over the lazy dog. Your task here is to write a function to check a sentence to see if it is a pangram or not 4 List & Tuples Aim: a. Write a program that takes two lists and returns True if they have at least one common member. b. Write a Python program to print a specified list after removing the 0th, 2nd, 4th and 5th elements. 5 Dictionary Aim: a. Write a Python script to sort (ascending and descending) a dictionary by value. b. Write a Python program to sum all the items in a dictionary. 6 Functions Aim: a. Write a Python Program to Find LCM and HCF. b. Write a Python Program to Find ASCII value of a character. c. Write a Python Program to Make a Simple Calculator 7 Arrays Aim: a. Write a python program to access a range of items in an array by using the slicing operator. b. Write a Python program To create an array of numeric values. Experiment No.1: Basic Python Programs Aim: a) To write and execute a Python program to display “Hello World”. b) To write and execute a Python program to add two numbers entered by the user. c) To write and execute a Python program to find the square root of a given number. d) To write and execute a Python program to calculate the area of a triangle. Tools & Technologies used: Programming Language: Python IDE: IDLE (Integrated Development and Learning Environment) Command Line Interface: Terminal or Command Prompt Learning Objectives: (a): Hello World ● The learning objective of the Hello World program is to: ● Understand the basic structure of a Python program ● Learn how to use the print() function ● Display output on the screen ● Get familiar with writing and running a simple Python program (b): Add Two Numbers ● The learning objective of this program is to: ● Understand the use of variables in Python ● Learn how to take input from the user ● Perform addition operation ● Display the result using the print() function (c): Find Square Root of a Number ● The learning objective of this program is to: ● Understand the concept of square root ● Learn how to use the math module in Python ● Take input from the user ● Calculate the square root of a number ● Display the result using the print() function (d): Find Area of a Triangle After completing this program, the learner will be able to: 1. Understand mathematical formulas ○ Learn the formula for calculating the area of a triangle: Area = ½ × base × height 2. Use user input in Python ○ Accept numerical values from the user using the input() function. 3. Apply type conversion ○ Convert input values into floating-point numbers using float() for accurate calculations. 4. Perform arithmetic operations ○ Use multiplication and division operators to compute the area. 5. Display results clearly ○ Output the calculated area using the print() function. Theory: (a) Theory: Hello World Program The "Hello World" program is usually the first program written by beginners in any programming language. It helps in understanding the basic structure of a Python program and the use of the print() function, which is used to display output on the screen. Example: print("Hello World") This statement prints the text Hello World on the output screen. (b) Theory: Addition of Two Numbers This program demonstrates how Python takes input from the user using the input() function and performs arithmetic operations. The entered values are converted into integers using int() before performing addition. The result is then displayed using the print() function. Example: a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print("Sum =", a + b) This program adds two numbers entered by the user and displays their sum. (c) Theory: Square Root of a Number Python provides a built-in library called math that contains various mathematical functions. The sqrt() function from the math module is used to calculate the square root of a given number. This program explains how to import a module and use its functions. Example: import math num = float(input("Enter a number: ")) print("Square root =", math.sqrt(num)) This program calculates and displays the square root of the given number. (d) Theory: Program to Find Area of a Triangle The area of a triangle is calculated using the mathematical formula: Area = ½ × Base × Height In this program, Python takes the values of the base and height from the user using the input() function. These values are converted into floating-point numbers using float() to allow decimal inputs. The formula for the area of a triangle is then applied, and the calculated The result is displayed on the screen using the print() function. This program helps in understanding user input, arithmetic operations, and formula implementation in Python programming. Code: (a) hello world Output : Code : (b) Add 2 numbers Output : Code : ( c ) square root Output : Code : (d) Area of triangle Output : Learning Outcomes: a) Display output in Python ● Understand the basic structure of a Python program and use the print() function to display the message “Hello World”. b) Perform basic arithmetic operations ● Take input from the user and apply arithmetic operators to add two numbers. c) Use built-in modules and functions ● Import and use the math module to calculate the square root of a given number. d) Apply mathematical formulas using Python ● Accept user input and calculate the area of a triangle using the formula Area = ½ × base × height. Course Outcomes a) Understand basic Python syntax and output statements ● Write and execute a simple Python program to display the message “Hello World” using the print() function. b) Apply input–output operations and arithmetic logic ● Develop Python programs to accept user input and perform basic arithmetic operations such as the addition of two numbers. c) Use built-in libraries for mathematical computation ● Implement Python programs using the math module to calculate the square root of a given number. d) Solve simple real-world problems using Python ● Design and execute Python programs to calculate the area of a triangle by applying appropriate mathematical formulas. Conclusion: Viva questions : 1) What is Python and what are its main features? 2) What is the use of the print() function in Python? 3) How do you take input from the user in Python? 4) How do you calculate the square root of a number in Python? 5) Write the formula to calculate the area of a triangle. 6) What is the difference between int() and float() in Python? For Faculty use: Experiment No.2: Conditional execution Aim: a. Write a Python Program to Check Leap Year. b. Write a Python Program to Find the Largest Among Three Numbers c. Write a Python Program to Check Prime Numbers. d. Write a Python Program to Find the Factorial of a Number. e. Write a Python Program to convert kilometers to miles. Tools & Technologies used Programming Language: Python IDE: IDLE (Integrated Development and Learning Environment) Command Line Interface: Terminal or Command Prompt Learning Objectives: a. Check Leap Year 1. Understand Conditional Statements: Learn how to use if, else, and logical operators to control program flow based on conditions. 2. Implement Basic Algorithms: Gain experience in implementing an algorithm to determine whether a year is a leap year based on specific rules. 3. Input Handling: Practice taking user input and converting it to the appropriate data type (integer). b. Find the Largest Among Three Numbers 1. Use of Functions: Understand how to define and call functions in Python. 2. Utilize Built-in Functions: Learn to use Python's built-in max() function for finding the largest value among multiple inputs. 3. List and Tuple Unpacking: Gain familiarity with handling multiple inputs using lists and unpacking them into function arguments. c. Check Prime Number 1. Looping Constructs: Develop skills in using loops (for/while) to iterate over a range of numbers. 2. Mathematical Logic: Understand the concept of prime numbers and how to implement logic to check primality. 3. Efficient Algorithms: Learn about optimizing algorithms by checking divisibility only up to the square root of the number. d. Find the Factorial of a Number 1. Recursive vs Iterative Approaches: Explore both recursive and iterative methods for calculating factorials (the provided example uses an iterative approach). 2. Error Handling: Understand how to handle edge cases, such as negative input, by implementing conditional checks. 3. Looping Constructs: Reinforce skills in using loops for calculations. e. Convert Kilometres to Miles 1. Unit Conversion: Learn about unit conversion and how to apply mathematical formulas in programming. 2. Function Definition: Practice defining functions that take parameters and return calculated results. 3. Input and Output: Enhance skills in handling user input and formatting output for clarity. Theory: a. Checking a Leap Year in Python 1. Understanding Leap Years A leap year is defined by specific rules: • A year is considered a leap year if it is divisible by 4. • However, if the year is divisible by 100, it is not a leap year, unless: • The year is also divisible by 400, in which case it is a leap year. For example: • 2000 is a leap year (divisible by 400). • 1900 is not a leap year (divisible by 100 but not by 400). • 2020 is a leap year (divisible by 4 but not by 100). • 2021 is not a leap year (not divisible by 4). 2. Conditional Statements In Python, conditional statements (if, elif, and else) are used to execute code based on certain conditions. The basic structure of an if statement allows the program to evaluate whether a condition is true or false and execute corresponding blocks of code. 3. Logical Operators Logical operators such as and, or, and not are used to combine multiple conditions. In the context of checking for leap years, you will often use these operators to evaluate whether multiple criteria are satisfied. 4. Input Handling Python provides built-in functions like input() for taking user input. The input received from users is typically in string format, so it must be converted to an integer using int() when performing arithmetic operations. 5. Putting It All Together The complete program combines all these elements into a cohesive unit. Here’s how the program works step-by-step: 1. Prompt the user to enter a year. 2. Convert the input from string to integer. 3. Apply the leap year rules using conditional statements. 4. Print whether the entered year is a leap year or not based on the evaluation. b. Finding the Largest Among Three Numbers in Python 1. Understanding the Problem The task is to compare three numerical values and identify the largest one. This can be approached in several ways, including using conditional statements or built-in functions. The basic logic involves comparing each number against the others to determine which is the greatest. 2. Conditional Statements Conditional statements (if, elif, and else) are essential for controlling the flow of a program based on specific conditions. In this case, you will use these statements to compare the three numbers. 3. Using Functions Defining functions in Python allows you to encapsulate code into reusable blocks. This promotes modularity and makes your code easier to read and maintain. In this case, you can define a function that takes three numbers as arguments and returns the largest. 4. Input Handling Python provides built-in functions like input() for taking user input. When users provide input, it is typically in string format, so you must convert it to an appropriate numerical type (e.g., integer or float) for comparison. 5. Implementing Comparison Logic To find the largest number among three inputs, you can use a series of conditional checks: • Compare the first number with the second and third. • Compare the second number with the first and third. • Compare the third number with the first and second. Alternatively, you can leverage Python's built-in max() function, which simplifies finding the maximum value among multiple inputs. c. Checking a Prime Number in Python 1. Understanding Prime Numbers A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a prime number can only be divided evenly (without leaving a remainder) by 1 and the number itself. Examples of Prime Numbers: • 2 (the only even prime number), 3, 5, 7, 11. Non-Prime Numbers: • 1 (not considered prime), 4 (divisible by 1, 2, and 4) , 6 (divisible by 1, 2, 3, and 6). 2. Basic Properties of Prime Numbers To determine if a number nn is prime: • If nn is less than or equal to 1, it is not prime. • If nn is exactly 2, it is prime. • If nn is greater than 2 and even, it is not prime. • For odd numbers greater than 2, check for factors from 3 up to the square root of nn. 3. Conditional Statements Conditional statements (if, elif, and else) are used to control the flow of the program based on specific conditions. In this case, you will use these statements to evaluate whether a number meets the criteria for being prime. 4. Looping Constructs Loops are crucial for iterating over a range of numbers. In this case, you will use a loop to check for factors of the given number. The most efficient way to check for factors is to iterate from 2 up to the square root of nn, as any factor larger than the square root would have a corresponding smaller factor. 5. Input Handling Python provides built-in functions like input() for taking user input. The input received from users is typically in string format, so it must be converted to an integer using int() when performing arithmetic operations. d. Write a Python Program to Find the Factorial of a Number. 1. Understanding Factorial The factorial of a non-negative integer nn is the product of all positive integers less than or equal to nn. It is denoted by n!n!. Mathematical Definition: • n!=n×(n−1)×(n−2)×...×2×1n!=n×(n−1)×(n−2)×...×2×1 • Special case: 0!=10!=1 Examples: • 5!=5×4×3×2×1=1205!=5×4×3×2×1=120 • 3!=3×2×1=63!=3×2×1=6 • 1!=11!=1 • 0!=10!=1 2. Recursive vs. Iterative Approaches Factorials can be computed using two primary approaches: • Recursive Approach: A function that calls itself to solve smaller instances of the same problem. Example Recursive Definition: • Base case: If n=0n=0 or n=1n=1, return 1. • Recursive case: Return n×(n−1)!n×(n−1)!. • Iterative Approach: Using loops to calculate the factorial by multiplying numbers from 1 to nn. Both methods are valid; however, recursion can lead to stack overflow for large values due to deep recursion, while iteration is generally more memory efficient. 3. Conditional Statements Conditional statements (if, elif, and else) are essential for controlling the flow of the program based on specific conditions. In this case, you will use these statements to handle special cases like negative inputs and base cases for recursion. 4. Looping Constructs Loops are crucial for iterating through a range of numbers. In an iterative approach, you would use a loop to multiply numbers from 1 up to nn. Code: a. Write a Python Program to Check Leap Year. Output: b. Write a Python Program to Find the Largest Among Three Numbers Output : c. Write a Python Program to Check Prime Numbers. Output : d. Write a Python Program to Find the Factorial of a Number. Output : e. Write a Python Program to convert kilometers to miles. output : Learning Outcomes: 1. Understand how to determine if a year is a leap year based on specific divisibility rules. 2. Learn to compare multiple values and identify the largest using built-in functions. 3. Gain knowledge on how to check for prime numbers using iteration and mathematical properties. 4. Understand how to calculate the factorial of a number using iterative methods. 5. Learn how to convert units of measurement from kilometers to miles using multiplication. Course Outcomes: 1. Implement Conditional Logic: Develop programs that utilize conditional statements to determine properties of numbers, such as identifying leap years and checking for prime numbers. 2. Utilize Built-in Functions: Leverage Python's built-in functions and libraries to perform operations like finding the maximum value among multiple inputs and calculating factorials. 3. Understand Mathematical Concepts: Apply fundamental mathematical concepts through programming, including divisibility rules for leap years and prime number verification. 4. Perform Unit Conversions: Write functions to convert between different units of measurement, demonstrating an understanding of real-world applications of programming. 5. Enhance Problem-Solving Skills: Strengthen problem-solving abilities by breaking down complex tasks into manageable functions and using iterative logic to achieve desired outcomes Conclusion: