Document 12
Document 12
INTRODUCTION
2
Python
3
User-defined functions in Python allow programmers to
create reusable blocks of code that perform specific tasks,
enhancing code modularity and readability. A function is
defined using the def keyword, followed by the function
name, parentheses, and a colon. Within the parentheses,
parameters can be specified to pass data into the function.
The function body is indented and contains the code to be
executed when the function is called. Functions can return
values using the return statement.
For example:
print("Adult")
else:
print("Minor")
count = 0
while count < 5:
print(count)
count += 1
5
Combining these constructs allows for the creation of
dynamic and efficient programs capable of handling
complex tasks and data processing, forming the backbone
of most Python applications.
6
and support various operations like indexing, slicing,
appending, and removing elements. For example:
7
15 Programs:
1) Conditional and iterative
programming
8
Program 1: Checking if a year is a leap year
Output:
9
Program 2: Checking if a string contains a certain
character
Output:
10
Program 3: Assigning a letter grade based on a
numerical score
Output:
11
Program 4: to make a triangle using numbers
Output:
12
Program 5: to make a program of while loop with a
bouncing ball
Output:
13
2)User defined functions
Program 1: Function that gives the square roots of
the number passed
Output:
14
Program 2: To get the factorial of a number
Output:
15
Program 3: To find the area of a right-angled triangle
Output:
16
Program 4: To make a to do list
17
Output:
18
Program 5: Program to add two numbers
Output:
19
3) List, tuples and Dictionaries
Program1: To return the largest number in a list
Output:
20
Program 2: To calculate the average of the numbers
in a list
Output:
21
Program 3: To concatenate two tuples
Output:
22
Program 4: Creating a dictionary from tuples
Output:
Output:
23
5 PROGRAMMES CONTAINING
MYSQL QUERIES
24
PROGRAM 1: CREATING A
DATABASE AND A TABLE AND
INSERTING VALUES
25
Output:
26
Program 2: Finding the top 3
students from the table
Output:
27
Program 3: Counting how many
students from each city
Output:
28
Program 4: Displaying students by
class sorting by marks
Output:
29
Program 5: Selecting name from
students where marks > 90
Output:
30
5 Programs containing my
SQL connectivity
31
Program 1 : Connecting to mySQL
Output:
32
Program 2: Creating a database
Output:
33
Program 3: Creating a table
Output:
34
Program 4: Insert Data into the
Table
Output:
35
Program 5: Retrieve Data from the
Table
Output:
36
Bibliography
1)freecodecamp.org
2)programmiz.com
3)geeksforgeeks.org
4)google.com
37