0% found this document useful (0 votes)
5 views

Python PDF

Uploaded by

gyanchod23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python PDF

Uploaded by

gyanchod23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1] What are the properties of a Dictionary?

->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.

2] What the use of an import statement with an example?

->the import statement is used to include external modules or libraries in your code allowing
you to access their functions are classes.

ex- import math // result=math.sqrt(25) // print(result)

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.

4] Write the definition of class method?

->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.

5] Write the syntax of the Raise statement and explain it?

->raise[ExceptionType[,message]]

is the type of exception you want to raise such as valueError or TypeError.

6] List out Geometry management method?

->1]pack()-this method arrange widgets in block either vertically or horizontally.2]grid()-this


method organizer widgets in a grid format using rows and columns.3]place()-this method
allows for precise placement of widgets at specific x and y coordinates within the parent
widget.

7] What is tkinter in python?

->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.

8] Break and pass statement in python?

->1]break-break statement in python is used to exit a loop prematurely. when encountered, it


stopes the loop and continues with the next statement outside the loop. 2]pass-pass statement
is a null operation it does nothing when executed.

9] Write any two common exception in python?

->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]Arithmetic Operators 2]Comparison Operators 3]Logical Operators 4]Unary Operators


5]Bitwise Operators 5]Container and sequence operators 6]String Representation.

11] Explain any two tuple operations with an example?

->1]Concatenation-this operation combines two or more tuples into a new tuple.2]slicing-this


operation allows you to access a portion of a tuple by specifying a range in indices.

12] What is the use of + and * operators on tuple?

->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.

13] What is the use of random() in random module?

->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

14] What is the syntax of constructer in python?

->class name:

def__init__(self, parameters):

self.attribute1=value1

15] What is the use of try-finally block?

->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.

16] List out any 5 Button options in python?

->1]Button 2]Checkbutton 3]Radiobutton 4]Entry 5]Scale.

17] What is advantages of pandas?

->1]Data manipulation 2]Data Structures

18] State the uses of tensor flow?

->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

19] Explain function Arguments in detail?

->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.

21] Explain math built-in-module with example?

->the build-in-module in python provide a wide range of mathematical function and constants
that can be used to perform various calculations.

22] Explain Exception handling in python with example?

->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.

23] Explain methods for geometry management in tkinter with example?

->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.

24] Explain function to delete element in Dictionary?

->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.

25] What is python? What are the benefits of using python?

->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.

27] Write in brief anonymous function?

->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))

28] Explain frame widget in tkinter with an example?

->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)

Different=1]List-list can be changed(mutable) 2]tuple-Tuple cannot be change(immutable)

30] What are the common built in data types in python?

->1]Integers(int):whole numbers, both positive and negative. Ex-'10''-10'. 2]Floation-point


numbers(float):numbers with decimal points. EX-'3.34'. 3]String(str):sequences of characters
used for text. EX-"hello". 4]Booleans(bool):represents 'true' or 'false' other used in conditions
and logical operations. 5]Lists(list):ordered mutable collections of items. EX-[1,2,3].
6]Tuples(tuple):ordered immutable collection. EX-(1,2,3). 7]Dictionary(dict):collection of key-
value pairs. Ex-{'name':'karan'}. 8]Sets(set):unordered collection of unique items. Ex-{1,2,3}
31] Which are built in exception in python?

->1]ArithmeticError: Base class for arithmetic-related exceptions.2]ZeroDivisionError: Raised


when dividing by zero.3]OverflowError: Raised when the result of an arithmetic operation is too
large to be expressed.4]AssertionError: Raised when an assert statement fails.5]AttributeError:
Raised when an invalid attribute reference is made.6]EOFError: Raised when the input()
function hits an end-of-file condition.7]ImportError: Raised when an import statement fails to
find the module.8]IndexError: Raised when a sequence subscript is out of range.9]KeyError:
Raised when a dictionary key is not found.10]NameError: Raised when a local or global name is
not found.11]TypeError: Raised when an operation or function is applied to an object of
inappropriate type.12]ValueError: Raised when a built-in operation or function receives an
argument that has the right type but an inappropriate value.

32] Write the principles of keras?

->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.

33] Explain the features of pandas in python?

->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?

->An assertion in programming is a statement used to test whether a condition is true at a


specific point in the code. it acts as a debugging aid that helps developers identify and catch
error early in the development process.in python assertion are made using the Assert keyword
followed by a condition.

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.

38] Raise Statement?

->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.

You might also like