0% found this document useful (0 votes)
12 views19 pages

Traning Report

Uploaded by

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

Traning Report

Uploaded by

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

PROGRAMMING LANGUAGE USED

Introduction to Python:

I have done my training in Python with MY SQL. Python is an easy to learn, powerful
programming language. Python is a high-level, interpreted programming language known for its
simplicity, readability, and versatility. Developed by Guido van Rossum and first released in
1991, Python has since gained widespread popularity among programmers, both beginners and
professionals alike. Its design philosophy emphasizes code readability and a clean syntax,
making it easy to learn and write code in Python.
Features of Python:
1. Readable and Beginner-Friendly Syntax
2. Cross-Platform Compatibility
3. Comprehensive Standard Library
4. Extensive Ecosystem of Packages and Frameworks
5. Dynamic Typing and Automatic Memory Management
6. Support for Multiple Programming Paradigms
7. Interpreted Language for Rapid Development
8. Easy Integration with Other Languages
9. Strong Community and Support
10. Scalability and Versatility
Some popular Python Libraries:

1. NumPy: Numeric computing library for efficient array manipulation and mathematical
operations.
2. Pandas: Data analysis and manipulation library, providing data structures and tools for
handling structured
data.
3. Matplotlib: Plotting and visualization library for creating charts, graphs, and other visual
representations of
data
4. TensorFlow: Machine learning library for building and training neural networks and other
machine learning
models.
5. Scikit-learn: Machine learning library with various algorithms for classification, regression,
clustering, and
more.

6. Flask: Lightweight web framework for building web applications and APIs.
7. Django: Full-featured web framework for developing robust and scalable web applications.
8. SQLite3: Module for interacting with SQLite databases, allowing database creation, querying,
and management.
9. random: Module for generating random numbers and making random selections.
10. tkinter: Module for creating GUI applications and windows with various widgets and
controls.

Advantages of Python:
1. Readability and Simplicity: Python's clean and easy-to-read syntax makes it highly
readable and reduces
the cost of program maintenance.
2. Large Standard Library: Python comes with a comprehensive standard library, offering a wide
range of
modules and functions for common programming tasks, reducing the need for external
dependencies.
3. Extensive Third-Party Ecosystem: Python has a vibrant ecosystem of third-party libraries and
frameworks
that provide ready-to-use solutions for various domains, such as data analysis, machine learning,
web
development, and more.
4. Cross-Platform Compatibility: Python programs can run on different operating systems,
ensuring
compatibility and portability.
Disadvantages of Python:
1. Performance: Python is an interpreted language, which can result in slower execution speed
compared to
compiled languages like C or C++. However, this drawback is mitigated by using optimized
libraries and
modules written in lower-level languages.
2. Global Interpreter Lock (GIL): The GIL is a mechanism in Python that allows only one thread
to execute
Python bytecode at a time, potentially limiting the performance of multi-threaded applications.
3. Mobile and Browser Support: Python is not as commonly used for mobile app development or
client-side
web development compared to languages like Java or JavaScript.
4. Database Access: Although Python offers database support through modules like SQLite3 and
connectors
for other databases, it may not be as robust or performant as specialized database languages or
frameworks
INTRODUCTION TO TKINTER

TKINTER- PYTHON LIBRARY:

Tkinter is a built-in Python library used for creating graphical user interfaces (GUIs) for desktop
applications.It provides a set of pre-built widgets and tools that enable developers to design and
build interactive windows, buttons, menus, text boxes, labels, and other GUI elements.
KEY FEATURES OF TKINTER:
1. Built-in Python Library: Tkinter is a standard library in Python, so no additional installation is
required.
2. GUI Widget Set: It provides a wide range of pre-built GUI widgets, including buttons, text
boxes, labels, checkboxes, dropdown menus, and more.
3. Event-Driven Programming: Tkinter supports event-driven programming, allowing developers
to define actions or functions to be triggered by user interactions, such as button clicks or mouse
movements.
4. Layout Management: Tkinter offers layout managers that help in organizing and arranging
GUI elements within a window, ensuring a consistent and responsive user interface.
5. Customization Options: Developers can customize the appearance and behavior of GUI
elements,including colors, fonts, sizes, and styles, to create visually appealing applications.
6. Cross-Platform Compatibility: Tkinter applications can run on different operating systems,
including Windows, macOS, and Linux, with minimal modifications.
7. Integration with Python: Tkinter seamlessly integrates with other Python libraries and
frameworks, allowing developers to leverage additional functionalities as needed.
8. Rapid Development: Tkinter simplifies GUI development with its intuitive API and drag-and-
drop support, enabling developers to quickly build interactive applications.
9. Community Support: There is a large and active community of Tkinter users who share
resources, tutorials, and code snippets, making it easy to find assistance and solutions to common
problems.

INTRODUCTION TO MySQL
MySQL is a popular relational database management system (RDBMS) that is used to store,
manage, and retrieve structured data. It is a server-client system where the MySQL server
handles database operations, while client applications interact with the server to perform tasks
like querying data, updating records, and managing the database structure. MySQL uses a
structured query language called SQL to interact with the database.
Key features of MySQL include:
1. Data storage and retrieval: MySQL provides efficient and scalable storage and retrieval of
structured data in tables.
2. SQL Queries: It supports SQL queries for performing operations such as data insertion,
deletion, updating, and data retrieval from the database.
3. Data Integrity and Security: MySQL enforces data integrity constraints and provides security
measures to protect sensitive data.
4. Scalability and Performance: MySQL is designed to handle large amounts of data and high
performance requirements, making it suitable for enterprise-level applications

Topics Under Python


 Variables
Variables are containers for storing data values.
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
Eg. x= 5
y = "John"
x and y are variables here

 Data Types

In programming, data type is an important concept.

Variables can store data of different types, and different types can do different
things.

Python has the following data types built-in by default, in these categories:

Text Type: str

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Set Types: set, frozenset

Boolean Type: Bool

 Type Casting

There may be times when you want to specify a type on to a variable. This can be
done with casting. Python is an object-orientated language, and as such it uses
classes to define data types, including its primitive types.

Casting in python is therefore done using constructor functions:


 int() - constructs an integer number from an integer literal, a float literal (by
removing all decimals), or a string literal (providing the string represents a whole
number)
 float() - constructs a float number from an integer literal, a float literal or a string
literal (providing the string represents a float or an integer)
 str() - constructs a string from a wide variety of data types, including strings,
integer literals and float literals

Eg.

y = int(2.8) # y will be 2
z = int("3") # z will be 3

a = float(2.8) # y will be 2.8


b = float("3") # z will be 3.0

 Python Operators

Operators are used to perform operations on variables and values.

Python divides the operators in the following groups:

1.Arithmetic operators:
Arithmetic operators are used with numeric values to perform common
mathematical operations.
2.Assignment operators:
Assignment operators are used to assign values to variables.
3.Comparison operators:
Comparison operators are used to compare two values.

4.Logical operators:
Logical operators are used to combine conditional statements.

5.Identity operators
Identity operators are used to compare the objects, not if they are equal,
but if they are actually the same object, with the same memory location.
6.Membership operators
Membership operators are used to test if a sequence is presented in an
object.

 Conditional Statements
Conditional statements (if, else, and elif) are fundamental programming
constructs that allow you to control the flow of your program based on conditions
that you specify

Syntax:
If condition:
# code to execute if condition is True

If condition:
# code to execute if condition is True
else:
# code to execute if condition is False
if condition1:
# code to execute if condition1 is True
elif condition2:
# code to execute if condition2 is True
elif condition3:
# code to execute if condition3 is True
else:
# code to execute if all above conditions are False

 For Loop

A for loop is used for iterating over a sequence (that is either a list, a tuple, a
dictionary, a set, or a string).

This is less like the for keyword in other programming languages, and works
more like an iterator method as found in other object-orientated programming
languages.

Syntax:

for item in iterable:


# code to be executed for each item

 Strings

A string in Python is a sequence of characters enclosed in quotes. Strings are


immutable, meaning their content cannot be changed after they are created.

 Immutable: Once created, the content of a string cannot be changed.


 Sequence Type: Supports indexing and slicing.
 Iterable: Can be looped over using a for-loop.
 Methods: Provides a variety of methods for string manipulation.

Eg. string1 = 'Hello, World!'

 List

A list in Python is an ordered collection of items, which can be of different


types. Lists are mutable, allowing modification of their content.

 Mutable: Elements can be added, removed, or changed.


 Ordered: Elements have a defined order, and this order will not change
unless explicitly done.
 Allows Duplicates: Can contain duplicate elements.
 Dynamic Size: Can grow and shrink as needed.
 Iterable: Can be looped over using a for-loop.
Syntax

Li=[1,”hello”,44,True,4.4]

 Tuples

A tuple is similar to a list but is immutable. Once created, the elements of a


tuple cannot be changed.

 Immutable: Elements cannot be added, removed, or changed.


 Ordered: Elements have a defined order.
 Allows Duplicates: Can contain duplicate elements.
 Iterable: Can be looped over using a for-loop.

Syntax

tuple1 = (1, 2, 3, 4, 5)

 Sets

Definition

A set is an unordered collection of unique elements. Sets are mutable but do


not allow duplicate elements.

 Mutable: Elements can be added or removed.


 Unordered: No order is maintained for the elements.
 No Duplicates: Each element must be unique.
 Iterable: Can be looped over using a for-loop.

Syntax

set1 = {1, 2, 3, 4, 5}

 Dictionaries

Definition

A dictionary is a collection of key-value pairs. Each key is unique, and the


values can be of any type. Dictionaries are mutable

 Mutable: Key-value pairs can be added, removed, or changed.


 Unordered: Prior to Python 3.7, dictionaries were unordered. From
Python 3.7 onward, dictionaries maintain insertion order.
 Unique Keys: Keys must be unique, but values can be duplicated.
 Iterable: Can be looped over using a for-loop.

Syntax

Dic={“name”:”Raman”, “age”:22 , “gender”:”female”}

 File Handling

File handling in Python involves operations for reading from and writing to files.
Python provides built-in functions to create, read, write, and delete files

 Modes: Files can be opened in different modes (e.g., read, write, append).
 File Objects: Files are treated as objects with methods for handling file
operations.

Syntax:

# Open a file

file = open('filename.txt', 'mode')

# Read a file

content = file.read()

# Write to a file

file.write('Hello, World!')

# Close a file

file.close()

 Exception Handling

Exception handling in Python is used to manage errors and exceptions in a


program, ensuring the program can handle unexpected situations gracefully.

 Try Block: Code that might cause an exception is placed in the try block.
 Except Block: Code that executes if an exception occurs.
 Finally Block: Code that executes regardless of whether an exception
occurred.
Syntax:

try:

# Code that may cause an exception

except Exception as e:

# Code that runs if the exception occurs

finally:

# Code that runs no matter what

print("This will execute no matter what")

 Random Module

The random module in Python provides functions to generate random numbers


and perform random operations.

 Random Number Generation: Generate random integers, floats, and


sequences.
 Shuffling: Shuffle the order of elements in a list.
 Seeding: Initialize the random number generator to produce repeatable
results.

Syntax:

import random

# Generate a random integer between 1 and 10

rand_int = random.randint(1, 10)

# Generate a random float between 0 and 1

rand_float = random.random()

# Shuffle a list

random.shuffle(my_list)

# Seed the random number generator

random.seed(42)
 Functions

Functions in Python are blocks of reusable code that perform a specific task. They
can accept input arguments and return values.

 Defining Functions: Use the def keyword.


 Parameters and Arguments: Functions can take parameters and return
values.
 Docstrings: Functions can have documentation strings for describing their
purpose.

Syntax:

def function_name(parameters):

Docstring describing the function.

# Function body

return value

 Lambda Functions

Lambda functions in Python are anonymous functions defined using the lambda
keyword. They are used for creating small, one-time, and inline functions.

 Anonymous: They don’t require a name.


 Single Expression: Consist of a single expression.
 Concise: Useful for short operations.

Syntax:

# Lambda function syntax

lambda arguments: expression

# Example

add = lambda x, y: x + y

 Map

The map function applies a given function to all items in an input list (or other
iterable) and returns an iterator of the results.

Properties:
 Functional Programming: Applies a function to each element of an
iterable.
 Returns an Iterator: The result can be converted to a list if needed.

Syntax:

# Syntax of map

map(function, iterable)

# Example

numbers = [1, 2, 3, 4]

squared = map(lambda x: x**2, numbers)

print(list(squared)) # Output: [1, 4, 9, 16]

 Filter

Definition: The filter function constructs an iterator from elements of an iterable for
which a function returns true.

 Conditional Filtering: Filters elements based on a condition.


 Returns an Iterator: The result can be converted to a list if needed.

Syntax:

# Syntax of filter

filter(function, iterable)

# Example

numbers = [1, 2, 3, 4, 5]

even_numbers = filter(lambda x: x % 2 == 0, numbers)

print(list(even_numbers)) # Output: [2, 4]

 Object-Oriented Programming (OOP)


OOP in Python is a programming paradigm based on the concept of "objects,"
which are instances of classes. It allows for the organization of software design
around data and objects rather than functions and logic.

Properties:

 Class: A blueprint for creating objects (a particular data structure).


 Object: An instance of a class.
 Attributes and Methods: Classes can have attributes (data) and methods
(functions).
 Inheritance: Classes can inherit attributes and methods from other classes.
 Encapsulation: Restricting access to some of the object’s components.
 Polymorphism: The ability to present the same interface for different
underlying forms (data types).

Syntax:

# Define a class

class MyClass:

# Class attribute

class_attribute = 0

# Initializer / Instance attributes

def __init__(self, name):

self.name = name

# Instance method

def greet(self):

return f"Hello, {self.name}"

# Create an instance of the class

obj = MyClass("Alice")
# Access instance attributes and methods

print(obj.name) # Output: Alice

print(obj.greet()) # Output: Hello, Alice

You might also like