Traning Report
Traning Report
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 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
Data Types
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:
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.
Eg.
y = int(2.8) # y will be 2
z = int("3") # z will be 3
Python Operators
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:
Strings
List
Li=[1,”hello”,44,True,4.4]
Tuples
Syntax
tuple1 = (1, 2, 3, 4, 5)
Sets
Definition
Syntax
set1 = {1, 2, 3, 4, 5}
Dictionaries
Definition
Syntax
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
# Read a file
content = file.read()
# Write to a file
file.write('Hello, World!')
# Close a file
file.close()
Exception Handling
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:
except Exception as e:
finally:
Random Module
Syntax:
import random
rand_float = random.random()
# Shuffle a list
random.shuffle(my_list)
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.
Syntax:
def function_name(parameters):
# 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.
Syntax:
# 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]
Filter
Definition: The filter function constructs an iterator from elements of an iterable for
which a function returns true.
Syntax:
# Syntax of filter
filter(function, iterable)
# Example
numbers = [1, 2, 3, 4, 5]
Properties:
Syntax:
# Define a class
class MyClass:
# Class attribute
class_attribute = 0
self.name = name
# Instance method
def greet(self):
obj = MyClass("Alice")
# Access instance attributes and methods