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

Python Programming Key Concepts

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)
12 views6 pages

Python Programming Key Concepts

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

1 MARKS PYTHON IMP BY NCODERS

1)Who is the developer of python?


 Guido van Rossum
2)What is the output of 30//20 and 30/20 ?
 30 // 20 gives 1 (floor division)
 30 / 20 gives 1.5 (float division)
3)What is the output of type?
 The type() function returns the type of the object passed to it. Example: type(5)
returns <class 'int'>..
4)How to write x raised to power y in python?
 You can write x ** y.
5)The python____ statement forces a specified exception to occur.
 raise
6)___ keyword tell the python that function is generator.
 yield
7)What is the time complexity of the merge sort?
 O(n log n)
8)What is the complexity of binary search when the value of high-low is equal to
len(L)-1?
 O(log n)
9)Which function is used to save plot graph to file?
 savefig() in matplotlib
10)What is the full form of png?
 Portable Network Graphics
11)Dynamic programming was invented by___ in ___.
 Richard Bellman in the 1950s
12)In rooted binary tree, each non-root node has ___ parent.
 One parent
13)Give full form of CSV.
 Comma-Separated Values
14)Give full form of JSON.
 JavaScript Object Notation
15)Write down regular expression statement to find out all five character long word
from string "strl" and print on string
 [Link](r'\b\w{5}\b', str1)
1 MARKS PYTHON IMP BY NCODERS
16)What is the output of following code ? import re DOB = "08-10-1980 # This is
Date of Birth" print([Link] (r'\D', "",[Link] (r#.*$', "",DOB)))
 import re
 DOB = "08-10-1980 # This is Date of Birth"
 print([Link](r'\D', "", [Link](r'#.*$', "", DOB)))
 Output: 08101980
17)What is the output of print([Link])?
 It prints the dimensions (rows, columns) of dataset as a tuple, e.g., (rows,
columns).
18)What is the output of print([Link](5)) ?
 It displays the first 5 rows of dataset.
19)MSE stands for ___.
 Mean Squared Error
20)Dependent variable is also called ___.
 Target variable or Response variable
21)What is Tuple ?
 A tuple is an immutable, ordered collection of elements in Python, defined
using parentheses, e.g., tuple = (1, 2, 3)
22)What is Python ?
 Python is a high-level, interpreted programming language known for its
simplicity and readability, widely used in web development, data science,
automation, and more.
23)How many keywords are there in python 3.7 ?
 There are 33 keywords in Python 3.7.
24)Which character is used in Python to make a single line comment ?
 The # character.
25)What is Exception ?
 An exception is an error that occurs during program execution, disrupting the
normal flow of a program.
26)What is Assertions ?
 An assertion is a statement used to test if a condition in the code returns True;
if not, it raises an AssertionError.
27)Partition and exchange sort is ___
 Quick Sort
1 MARKS PYTHON IMP BY NCODERS
28)Parent class is the class being inherited from also called?
 The superclass or base class.
29)What is the default extension of PyLab Figure ?
 .png
30)PyLab provides many of the facilities of ____
 MATLAB
31)Which module of matplotlib library is required for plotting of graph ?
 pyplot
32)___ function is used to display figure/chart.
 show()
33)What is GUI?
 GUI stands for Graphical User Interface, allowing users to interact with
applications through graphical elements like buttons and windows.
34)What is mainloop ()?
 mainloop() is a function in GUI frameworks like Tkinter that runs the event loop
to keep the application window open and responsive.
35)What is TCL ?
 TCL stands for Tool Command Language, a scripting language often used with
Tkinter for GUI development in Python.
36)What is IP Address ?
 An IP address is a unique identifier for a device on a network, allowing devices
to communicate over the internet.
37)What does SQL stand for?
 Structured Query Language
38)____ method executes a database query from within Python.
 execute() (commonly used with the cursor object in database libraries like
sqlite3).
39)By default the order by clause sorts the result set in the ___ order.
 Ascending order
40)Which package import before writing database connectivity python code ?
 sqlite3 (or other specific database packages like [Link] or psycopg2
for MySQL and PostgreSQL, respectively)
41)IDLE stand for___
 Integrated Development and Learning Environment
1 MARKS PYTHON IMP BY NCODERS

42)Who is the developer of python ?


 Guido van Rossum
43)The ___ symbol is a shell prompt in phython.
 >>>
44)____ method read string from the an open file in python.
 read()
45)____exception catch all exception in python.
 Exception
46)ADT stands for___
 Abstract Data Type
47)____has a brief description about the class.
 A docstring (placed inside triple quotes """)
48)___ error is raised when division or modulo by zero takes a place for all numeric
types.
 ZeroDivisionError
49)PyLab is embedded with ___ module of python.
 Matplotlib
50)Give full form of png.
 Portable Network Graphics
51)Dynamic programming is mainly an optimization over plain ___
 Recursion
52)___ function is used to display chart/figure.
 show()
53)JSON stand for___
 JavaScript Object Notation
54)CSV stand for___
 Comma-Separated Values
55)R3egEx stand for___
 Regular Expression
56)If there is no match___ will be returned, instead of the Match object.
 None
57)ROC stand for
 Receiver Operating Characteristic
1 MARKS PYTHON IMP BY NCODERS
58)MAE stand for
 Mean Absolute Error
59)AUC stand for
 Area Under the Curve
60)MSE stand for
 Mean Squared Error
61)IDLE stands for
 Integrated Development and Learning Environment
62)___ is a special character, which is used to represent whitespace characters
 \s
63)___ is a special character, which is used for new line.
 \n
64)The ___ symbol is a shell prompt in Python.
 >>>
65)The ___ symbol is to set comments in Python.
#
66)Python commands are evaluated/executed in ___.
 An interpreter
67)____ method writes any string to an open file in Python.
 write()
68)___method reads string from an open file in Python
 read()
69)ADT Stands for_.
 Abstract Data Type
70)___ error is raised when a calculation exceeds maximum limit for a numeric
type.
 OverflowError
71)___ error is raised when an import statement fails.
 ImportError
72)___ has a brief description about the class.
 A docstring (inside triple quotes """)
73)Knapsack problem is also known as ___ problem.
 The optimization problem
1 MARKS PYTHON IMP BY NCODERS
74)PyLab is embedded with ___ module of Python.
 Matplotlib
75)___ method displays the graphical window on the computer screen.
 show()
76)Dynamic Programming is mainly an optimization over plain __
 Recursion
77)RegEx stands for ___
 Regular Expression
78)JSON stands for___
 JavaScript Object Notation
79)Notation ___ is used to match start of string.
^
80)Notation ___ is used to match end of string.
$
81)ROC Stands for___
 Receiver Operating Characteristic
82)MSE stands for___
 Mean Squared Error
83)AUC Stands for___
 Area Under the Curve
84)___ is informative tags to subsets of data
 Labels
85)___ is the process of exploring and analyzing large datasets to make predictions
and boost data- driven decision making.
 Data Mining
86)RMSE stands for__
 Root Mean Squared Error
87)ROC Stands for___
 Receiver Operating Characteristic
88)MAE stands for___
 Mean Absolute Error

Common questions

Powered by AI

Dynamic programming is an optimization technique that improves on basic recursion by storing the results of expensive function calls and reusing them when the same inputs occur again. This prevents unnecessary repeated calculations, significantly enhancing performance. In contrast, basic recursion might recompute the same values repeatedly, leading to exponential time complexity. Dynamic programming can reduce this to polynomial complexity, thus providing substantial performance improvements in problems like the Fibonacci sequence or knapsack problem, where overlapping subproblems exist .

The 'read()' and 'write()' methods in Python are integral to file handling but serve distinctly different functions. 'read()' reads content from a file into a string, which can be used to parse or interpret data as needed. It's typically used when processing and analyzing file contents, such as logs or user input. Conversely, 'write()' sends data from a program to a file, overriding existing content unless specified otherwise. This makes 'write()' ideal for data output operations, such as saving results or configurations. These methods enable efficient interaction with file systems for data persistence and retrieval .

Regular expressions in Python significantly enhance text processing by providing a powerful tool to search, match, and manipulate strings based on complex patterns. Using functions like 'findall()', regular expressions can identify all occurrences of specified patterns within a string, facilitating operations such as data validation, parsing structured text (e.g., log files, structured.csv data), and transforming text. 'findall()' returns all non-overlapping matches, making it efficient for tasks where multiple results need to be considered, such as extracting specific data formats or identifying repeated elements across large text data sets .

The 'savefig()' function in matplotlib is essential for preserving visual representations of data by saving plots to files. This capability allows users to export visualizations as image or vector formats (e.g., PNG, PDF), enabling easy inclusion in reports, presentations, or further analysis. By controlling the output format and resolution, 'savefig()' enhances the flexibility and quality of data visualizations for varied uses, ensuring data insights are effectively communicated across platforms and can be reused or referenced independently of the generating environment .

The 'type()' function in Python is crucial for determining the data type of an object at runtime. It returns the type of the object passed as an argument, facilitating dynamic type checking and helping developers understand what operations can be performed on those objects. This is particularly useful for debugging, ensuring type compatibility, and for dynamic attribute assignment in object-oriented programming. Knowing an object's type additionally guides developers in leveraging Python's dynamic typing system more effectively .

In Python, 'raise' is used to throw an exception manually, allowing a developer to explicitly signal various conditions as errors for a program to handle them. Its use enhances error handling by providing precise control over the flow of a program based on exceptional conditions. By specifying which exceptions can occur and handling them directly, programs can manage unexpected situations predictably by invoking error-specific responses, such as logging or user alerts, rather than merely terminating the execution .

The 'execute()' method in Python, often used in conjunction with database cursor objects, plays a critical role in executing SQL queries within a Python environment. It simplifies the process of sending commands to a database, including performing CRUD operations like creating tables, querying data, updating records, and deleting entries. Typical use cases include executing parameterized queries that help prevent SQL injection attacks and manage transaction controls effectively. Its impact lies in seamlessly integrating Python scripts with databases, thus facilitating dynamic and data-driven application development .

Docstrings serve as in-code documentation for Python classes and methods, enclosed within triple quotes directly below the class or method header. They provide a convenient way to document the purpose, parameters, return types, and any important notes on usage or exceptions related to classes and functions. This enhances code readability and maintainability by ensuring that specifications and usage instructions are available right where the code is implemented. Through tools like 'help()' or comments extraction techniques, this documentation is accessible directly from the code base without separate documentation files, promoting efficient developer communication and understanding .

The time complexity O(n log n) for merge sort signifies that its efficiency grows logarithmically in relation to the number of elements being sorted, making it more efficient for larger datasets compared to elementary algorithms like bubble sort or insertion sort which have quadratic time complexity, O(n^2). Merge sort is also stable and sorts in Θ(n log n) time in the worst case consistently, in contrast to quicksort which, although averages in O(n log n) time, can degrade to O(n^2) in its worst case without proper pivot selection. This reliability makes merge sort a good choice for guaranteed performance under diverse input conditions .

The 'yield' keyword in Python is used to convert a regular function into a generator. Instead of returning a single value, a generator function can pause midway and resume from where it left off, maintaining its execution state across invocations. When 'yield' is used, it allows the function to return a sequence of values over time, rather than computing them all at once and sending them back. It's particularly useful in scenarios where large data sets are involved or when the full dataset is not needed all at once, as it allows iteration over data without storing it entirely in memory, promoting efficient memory usage .

You might also like