Python PDF
Python PDF
->1]key-value pairs-a dictionary stores data in pairs where each key is unique and maps to a
specific value.2]Unordered-the items in a dictionary do not have a defined order, so the
arrangement of key-value pairs can vary.3]Mutable-you can modify a dictionary by adding,
removing, or changing key-value pairs after its has been created.
->the import statement is used to include external modules or libraries in your code allowing
you to access their functions are classes.
3] What is scikit-learn?
->scikit-learn is an open-source machine learning library for python that provides efficient tools
for data mining and data analysis. it includes a variety of algorithms for tasks like classification,
regression, and clustering marking it user-friendly for both beginners and exports.
->a class method in python is a method that is associated with the class itself rather than an
instance of the class. this is defined using the @classmethod decorator.
->raise[ExceptionType[,message]]
->Tkinter is a standard GUI toolkit in python that allows developer to create desktop application
with graphical interface.it provides various widgets like buttons, labels, and text boxes to build
user-friendly application.
->1]ValueError-this occurs when a function receives an argument of the current type but an
inappropriate value. 2]IndexError-this happens when you try to access an index that is out of
range for a list or other indexable data type.
10] List out special operators in python?
->1] + (concatenation)-this operator is used for combine two or more tuples into a new tuple.2]
* (Repetition)-this operator is used to repeat a tuple a specified number of times.
->the random() function in the random module is used to generate a random floating-point
number between 0.0 and 1.0 this means the output will always be greater than or equal to 0.0
and less than 1.0
->class name:
def__init__(self, parameters):
self.attribute1=value1
->the try-finally block in python is used for exception handling ensuring that certain code is
executed regardless of whether an exception occurs or not.
->1]Machine learning-its commonly used to build and train machine learning models.2]Deep
Learning-TensorFlow is popular for deep learning tasks like image and speed recognition
->function argument are value that you pass to a function when you call it. they allows you to
provide input to the function so that it can perform its task based on those input.TYPES-
1]position Argument-these are the most common type. the order in which you pass them
matter.2]Keyword Argument-you can specify argument by name allowing you to pass them in
any order.3]Default Argument-you can assign default value to arguments in the function
definition. if a value is not provided during the function call the default value is used.4]variable-
length Argument-these allows you to pass a variable number of argument. you can used * args
for non-keyword variable-length argument.
20] Explain any three widgets in tkinter in brief?
->1]label-the label widget is used to display text or images in your application. its great for
showing information to user. EX-you can create a label to display a greeting message.2]Button-
the button widget allows user to perform action when they click it. you can attach a function to
it so that when the button is clicked something happens like displaying a message or changing a
value.3]Entry-the entry widget is a single-line text input field where user can type in information.
its commonly used for getting user input such as names or search queries.
->the build-in-module in python provide a wide range of mathematical function and constants
that can be used to perform various calculations.
->Exception handling in python is a way to manage errors that occur during the execution of a
program allowing to continue running instead of crashing.1]try-this block contains the code
that mighty raise an exception.2]except-this block handles the exception if one occurs.3]else-
this block runs if no exception were raise in the try block.4]finally-this block executes
regardless of whether an exception occurred or not typically used for cleanup.
->in tkinter geometry management is refer to the way you control the placement and sizing of
widgets within a window. there are three main geometry management in thinter: pack, grid and
place. each has its own method of organizing widgets.
->dictionaries are versatile data structures that allows you to store key-value pairs. if you need
to delete elements from a dictionary there are several method you can use.1]del statement-this
method delete a specific key-value pair. if the key does not exist it raises a KeyError.2]pop()
method-this removes the specified key and return its value. you can provide a default value to
avoid error if the key is not found.3]popitem() method-this remove the list inserted key-value
pair and return it as a tuple. raises KeyError if the dictionary is empty.4]clear() method-this
removes all items from the dictionary leaving it empty.
->python is a high-level interpreted programming language that is known for its simplicity and
readability.it was created by guido van Rossum and released in 1991. BENEFIT-1]Easy to learn-
python has a simple syntax that resembles the English language, making it accessible for
beginners.2]Versatility-it can be used for various applications, such as web development, data
analysis, machine learning, and automation.3]Lage Community and Libraries-python has a
strong community and a vast standard library which means there are many resources and third-
party libraries available for developers.4]Cross-Platform-python runs on multiple operation
system, allowing code to be easily shared and executed across different platform.
26] Name any five built in modules in python?
->1]math-this module provides mathematical function like square root, trigonometric function,
and constants such as pi.2]OS-the OS module allows you to interact with the operation system,
enabling file and directory manipulation.3]SYS-this module provides access to system-specific
parameters and functions, such as command-line arguments and the python interaction
environments.4]Datetime-the datetime module is used for manipulation dates and time,
allowing you to work with date object and time intervals.5]random-this module is used for
generating random numbers and includes functions to select random items from a list and
shuffle date.
->Anonymous function in python are define using the lambda keyword. these functions are also
known as lambda function and are typically used for short, throwaway function that are not
meant to be reused later.1]Syntax-the syntax for a lambda function is lambda arguments:
expression, which is evaluated and returned.2]NO Name-lambda function do not have a name
unless you assign them to a variable.3]Common Use Cases-they are often used in functions
that require a function as an argument such as map(),filter(),and sorted(). 4]EX= add=lambda
X,Y:X+y print(add(3,4))
->in tkinter a frame widget is a container used to organize and group other widgets. it helps
create a structured layout for your application, making it easier to manage and separate
different sections visually.1]Organization-frame help in logically grouping related widgets,
improving the overall structure of the GUI.2]Customization-you can customize the appearance
of a frame by changing its background color, border width, and relief style.3]Nested Frames-
you can create frames within frames to build more complex layouts.
29] What are lists and tuples? What is the key different between the two?
->1]lists-a list is a mutable collection, meaning you can change its content after it has been
created. you can add, remove, or modify element within a list. list are defined using square
brackets. EX- my_list=[1,2,3] my_list.append(4) print(my_list) 2]tuple-on the other hand is an
immutable collection. once a tuple is created you cannot change its contents. tuple are define
using parentheses. EX- my_tuple=(1,2,3) my_tuple[0]=4 print(my_tuple)
->1]User-Friendly-keras is designed to be simple and intuitive, allowing users to build and train
models quickly without complex coding.2]Modularity-it features a modular architecture
meaning you can easily combine different components like layers and optimizers to create
complex models.3]Extensibility-keras allows for the creation of custom layers and models
providing flexibility for implementing new ideas in deep learning.4]Support for Multiple
backends-it can run on different backends including tensorflow and Theano, giving users the
freedom to choose the one that fits their needs best.
->1]Data Structures-pandas provides two primary data structure: Series and DataFrame. a
series is a one-dimensional labeled array, while a DataFrame is a two-dimensional labeled data
structure that can hold different data types similar to a table in a database.2]Data Alignment-
pandas automatically aligns data based on labels making it easy to work with data from
different sources and ensuring that operations are performed correctly.3]Handling Missing
Data-pandas has built-in methods for detecting removing and filling missing data, which is
crucial for data cleaning and preprocessing.4]Data manipulation-it offers a wide range of
functions for data manipulation including filtering grouping merging and reshaping data.
34] package
->in python a packages is a way of organizing related modules into a single directory hierarchy.
it allows for a structured approach to manage code making it easier to maintain and reuse. a
package typically contains an init py file, which can be empty or contain initialization code for
the package.
35] Tuple?
->A tuple is an immutable sequence type in python that can hold a collection of items. unlike
lists tuples cannot be modified after they are created which means you cannot add, remove, or
change elements. tuples are defined using parentheses and they can store mixed data types
including integers, string, and other object.
36] Assertion?
37] NumPy?
->NumPy is a powerful library in python that is primarily used for numerical and scientific
computing.it provide support for large multi-dimensional arrays and matrices along with a
collection of mathematical function to operate on these arrays. the key feature of NumPy is its
ndarray object which is a fast and flexible container for large data sets in python.
->the raise statement in python is used to trigger an exception.it allows you to create custom
error messages and handle exceptions in a controlled manner. you can raise build-in exception
or user-defined exceptions to indicate that an error has occurred in your program.