0% found this document useful (0 votes)
15 views37 pages

Document 12

Uploaded by

Dhyaan Kanoja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views37 pages

Document 12

Uploaded by

Dhyaan Kanoja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Name: Chinar Chhabria

Grade: XII Section: Science


Roll no: 7
Computer Science
Report File
Year:2024-2025
INDEX
1
Srno Content Pg no
1 Introduction 3-8
2 Programs
(1) Conditional 9-13
and iterative
programming
(2) User defined 14-19
functions
(3) Lists, 20-23
dictionaries and
tuples
3 5 MySQL 24-30
Programs
4 5 connectivity 31-35
programs
6 Bibliography 37

INTRODUCTION
2
Python

Python is a high-level, versatile programming language


known for its simplicity and readability. Developed by
Guido van Rossum and first released in 1991, Python's
syntax emphasizes code readability and allows developers
to express concepts in fewer lines of code compared to
other languages like Java or C++. It supports multiple
programming paradigms, including procedural, object-
oriented, and functional programming. Python is widely
used in various fields such as web development, data
analysis, artificial intelligence, scientific computing, and
automation. Its extensive standard library and vibrant
community contribute to its popularity and continuous
growth in the programming world.

1) User Defined functions

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.

In this example, greet is a user-defined function that takes


a single parameter name and returns a greeting message.
Functions can be called multiple times with different
arguments, making them powerful tools for code reuse.
They can also help in organizing complex programs into
simpler, manageable sections. Proper use of functions
leads to cleaner, more understandable, and maintainable
code, which is essential for both small scripts and large
applications.

2) Conditional and iterative


programming
4
Conditional and iterative programming are fundamental
concepts in Python that control the flow of a program.

Conditional programming uses if, elif, and else statements


to execute code blocks based on boolean conditions. This
allows programs to make decisions and perform different
actions depending on the input or state.

For example:

if age >= 18:

print("Adult")

else:

print("Minor")

Iterative programming involves looping constructs to


repeat a block of code multiple times. Python provides for
and while loops for this purpose. The for loop iterates
over a sequence (like a list or range), while the while loop

continues executing as long as a specified condition is


true. For example:

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.

3) Lists, Tuples and


Dictionary
In Python, lists, tuples, and dictionaries are fundamental
data structures that enable efficient data storage and
manipulation.
Lists are ordered, mutable collections of items, defined
using square brackets. They allow for dynamic resizing

6
and support various operations like indexing, slicing,
appending, and removing elements. For example:

fruits = ['apple', 'banana', 'cherry']


Tuples are like lists but are immutable, meaning their
elements cannot be changed after creation. They are
defined using parentheses and are often used for fixed
collections of items. For example:

coordinates = (10, 20)


Dictionaries are unordered collections of key-value pairs,
defined using curly braces. Keys must be unique and
immutable, while values can be of any type. Dictionaries
are ideal for mapping relationships and fast lookups. For
example:

person = {'name': 'Alice', 'age': 30}

These data structures are essential for organizing and


managing data efficiently in Python, each offering unique
advantages for different use cases.

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:

Program 5: Counting the frequency of characters in


a string

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

You might also like