Python uses modules, packages, and libraries to organize code. A module is a .py file containing functions, classes, and variables. Related modules are grouped into packages, which are directories containing an __init__.py file. Libraries are collections of packages that provide specific functionality. The Python standard library includes common modules like math and random. Modules can be imported and used to reuse code in other files or packages.
James Jesus Bermas on Crash Course on PythonCP-Union
This document provides an overview of the Python programming language. It introduces Python, discusses its uses in industries like Google and Industrial Light & Magic, and covers key Python concepts like data types, functions, object-oriented programming, modules, and tools. The document is intended to explain what Python is and give an introduction to programming in Python.
Python lists are mutable while tuples are immutable. Some key features of Python include being an interpreted, dynamically typed language well-suited for object-oriented programming. Python uses indentation to specify blocks of code within functions, classes, loops, etc. and functions are first-class objects that can be assigned to variables or passed into other functions.
PPT on Python - illustrating Python for BBA, B.Techssuser2678ab
This document provides an overview of the Python programming language. It outlines the topics that will be covered in a course on Python programming, including an introduction to Python, installing Python, data types, variables, strings, lists, tuples, sets, dictionaries, and functions. It also provides details on Python's history and design philosophy, and explains why Python is a popular language for tasks like data analysis, machine learning, and web development.
This document discusses Python packages, modules, and the use of the __init__.py file to define packages. It explains that packages allow for hierarchical structuring of modules using dot notation to avoid name collisions. Creating a package only requires making a directory with an __init__.py file and modules. The __init__.py file can initialize package-level data and automatically import modules. Importing from packages works similarly to modules but uses additional dot notation to separate packages from subpackages.
1. Modules allow the user to organize Python code into reusable files called modules and then import and use functionalities from those modules in other Python scripts and files.
2. Core Python modules like math, random, datetime etc. are bundled with the Python interpreter while third party modules need to be installed separately.
3. Packages are a way to group related modules together and avoid naming collisions, they create a hierarchical namespace and allow modules to be logically organized.
Kunal Chauhan will provide a 6-week Python training covering introduction to Python programming, basics of programming in Python, principles of object-oriented programming, SQLite database, developing GUI with PyQt, and applications of Python in various disciplines. The training will introduce Python as a programming language created in 1991 that works on different platforms. It will cover basic Python syntax, data types, operators, conditional and loop statements, functions, modules, and object-oriented programming concepts like classes and objects.
Python uses modules, packages, and libraries to organize code. A module is a .py file containing functions, classes, and variables. Related modules are grouped into packages, which are directories containing an __init__.py file. Libraries are collections of packages that provide specific functionality. The Python standard library includes common modules like math and random. Modules can be imported and used to reuse code in other files or packages.
James Jesus Bermas on Crash Course on PythonCP-Union
This document provides an overview of the Python programming language. It introduces Python, discusses its uses in industries like Google and Industrial Light & Magic, and covers key Python concepts like data types, functions, object-oriented programming, modules, and tools. The document is intended to explain what Python is and give an introduction to programming in Python.
Python lists are mutable while tuples are immutable. Some key features of Python include being an interpreted, dynamically typed language well-suited for object-oriented programming. Python uses indentation to specify blocks of code within functions, classes, loops, etc. and functions are first-class objects that can be assigned to variables or passed into other functions.
PPT on Python - illustrating Python for BBA, B.Techssuser2678ab
This document provides an overview of the Python programming language. It outlines the topics that will be covered in a course on Python programming, including an introduction to Python, installing Python, data types, variables, strings, lists, tuples, sets, dictionaries, and functions. It also provides details on Python's history and design philosophy, and explains why Python is a popular language for tasks like data analysis, machine learning, and web development.
This document discusses Python packages, modules, and the use of the __init__.py file to define packages. It explains that packages allow for hierarchical structuring of modules using dot notation to avoid name collisions. Creating a package only requires making a directory with an __init__.py file and modules. The __init__.py file can initialize package-level data and automatically import modules. Importing from packages works similarly to modules but uses additional dot notation to separate packages from subpackages.
1. Modules allow the user to organize Python code into reusable files called modules and then import and use functionalities from those modules in other Python scripts and files.
2. Core Python modules like math, random, datetime etc. are bundled with the Python interpreter while third party modules need to be installed separately.
3. Packages are a way to group related modules together and avoid naming collisions, they create a hierarchical namespace and allow modules to be logically organized.
Kunal Chauhan will provide a 6-week Python training covering introduction to Python programming, basics of programming in Python, principles of object-oriented programming, SQLite database, developing GUI with PyQt, and applications of Python in various disciplines. The training will introduce Python as a programming language created in 1991 that works on different platforms. It will cover basic Python syntax, data types, operators, conditional and loop statements, functions, modules, and object-oriented programming concepts like classes and objects.
This document discusses several popular Python libraries:
- NumPy is a fundamental package for scientific computing and machine learning that represents data as n-dimensional arrays. Its array interface allows representing images, sounds, and other data as arrays.
- Pandas allows working with and analyzing datasets, including functions for cleaning, exploring, and manipulating data. It can analyze big data and draw conclusions.
- Pyttsx3 is a text-to-speech library that can convert text to speech offline, unlike some other libraries.
- Wikipedia allows programmatically accessing and parsing data from Wikipedia, including searching, getting article summaries and linked data.
- Other standard Python modules discussed include datetime for date/time handling, webbrowser for controlling browsers,
This document discusses functions in Python. It defines functions as collections of statements that perform specific tasks. There are three types of functions: built-in functions, module functions, and user-defined functions. Built-in functions are predefined in Python, module functions are contained in .py files, and user-defined functions are created by the user. The document provides examples of various types of functions and how they can be called and used.
Kunal Chauhan will be conducting a 6 week Python training program from May 15th to June 26th. The training will cover introductory Python programming, basics of programming in Python including variables, data types, operators, and control flow, principles of object-oriented programming, SQLite database usage, GUI development with PyQt, and applications of Python in various disciplines like web development, machine learning, data science, and more.
1. The document discusses Python arrays, modules, and packages. It describes how to create and access elements of an array, as well as common array methods.
2. It explains what modules are and how to create, import, rename, and access attributes of modules. Dir() function and module search path are also covered.
3. Python packages and subpackages are defined. Steps to create packages and import from packages and subpackages are provided along with an example.
This document is a summer training report submitted by Shubham Yadav to the Department of Information Technology at Rajkiya Engineering College. The report details Shubham's 4-week training program at IQRA Software Technologies where he learned about Python programming language and its libraries like NumPy, Matplotlib, Pandas, and OpenCV. The report includes sections on the history of Python, its characteristics, data structures in Python, file handling, and how to use various Python libraries for tasks like mathematical operations, data visualization, data analysis, and computer vision.
Python is an interpreted, object-oriented programming language that uses indentation to identify blocks of code. It is dynamically typed and strongly typed, with objects determining types at runtime rather than requiring explicit type declaration. Common data types include mutable types like lists and dictionaries as well as immutable types like strings and tuples.
The document discusses Python interview questions and answers related to Python fundamentals like data types, variables, functions, objects and classes. Some key points include:
- Python is an interpreted, interactive and object-oriented programming language. It uses indentation to identify code blocks rather than brackets.
- Python supports dynamic typing where the type is determined at runtime. It is strongly typed meaning operations inappropriate for a type will fail with an exception.
- Common data types include lists (mutable), tuples (immutable), dictionaries, strings and numbers.
- Functions use def, parameters are passed by reference, and variables can be local or global scope.
- Classes use inheritance, polymorphism and encapsulation to create
This document provides an overview of Python basics for data analysis, including introductions to key Python packages like NumPy, Pandas, and Matplotlib. It covers fundamental Python concepts like data types, operators, conditional statements, loops and functions. It also demonstrates how to load and manipulate data with NumPy arrays and Pandas DataFrames, including indexing, slicing, grouping, merging, and handling missing values. Visualization with Matplotlib charts is also covered.
Chapter Functions for grade 12 computer ScienceKrithikaTM
1. A function is a block of code that performs a specific task and can be called anywhere in a program. Functions make code reusable, improve modularity, and make programs easier to understand.
2. There are three main types of functions: built-in functions, functions defined in modules, and user-defined functions. Built-in functions are pre-defined and always available, module functions require importing, and user-defined functions are created by programmers.
3. Functions improve code organization and readability by separating code into logical, modular units. Functions can take parameters, return values, and be called from other parts of a program or other functions. This allows for code reuse and modular programming.
This document provides an overview of Java utilities and collection classes. It discusses the Java Math class and methods for numeric operations. It also describes wrapper classes for primitive data types and lists the eight primitive types in Java. Finally, it provides an example of using the Collections class to sort, reverse, shuffle a list and check element frequencies.
A for loop is probably the most common type of loop in Python. A for loop will select items from any iterable. In Python an iterable is any container (list, tuple, set, dictionary), as well as many other important objects such as generator function, generator expressions, the results of builtin functions such as filter, map, range and many other items.
The document provides an introduction to the Python programming language. It discusses what Python is, its creator Guido van Rossum, and how to write a simple "Hello World" program. It also covers Python data types, operators, flow control using conditionals and loops, functions, input/output operations, and the Zen of Python philosophy guiding Python's design. The document serves as the first day of instruction in a Python course.
This document discusses Python libraries, including popular libraries for data analysis, web development, and machine learning. It provides examples of how to use the Matplotlib and NumPy libraries, describing their features and sample code. The key steps to install and import Python libraries using pip and import statements are also outlined. Overall, the document introduces several essential Python libraries and their applications.
The document provides information about various Python concepts like PEP 8, pickling, lambda functions, generators, modules, packages and more. It also includes questions about memory management in Python, tools for static analysis, decorators, iterators, slicing, and other common Python interview questions.
This document discusses functions in Python. It begins by defining what a function is and provides examples of built-in functions and functions defined in modules. It then lists some advantages of using functions such as code reusability and readability. The document discusses the different types of functions - built-in functions, functions defined in modules, and user-defined functions. It provides examples of each type. The document also covers topics such as function parameters, return values, variable scope, lambda functions, and using functions from libraries.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
Implementing ELDs or Electronic Logging Devices is slowly but surely becoming the norm in fleet management. Why? Well, integrating ELDs and associated connected vehicle solutions like fleet tracking devices lets businesses and their in-house fleet managers reap several benefits. Check out the post below to learn more.
This document discusses several popular Python libraries:
- NumPy is a fundamental package for scientific computing and machine learning that represents data as n-dimensional arrays. Its array interface allows representing images, sounds, and other data as arrays.
- Pandas allows working with and analyzing datasets, including functions for cleaning, exploring, and manipulating data. It can analyze big data and draw conclusions.
- Pyttsx3 is a text-to-speech library that can convert text to speech offline, unlike some other libraries.
- Wikipedia allows programmatically accessing and parsing data from Wikipedia, including searching, getting article summaries and linked data.
- Other standard Python modules discussed include datetime for date/time handling, webbrowser for controlling browsers,
This document discusses functions in Python. It defines functions as collections of statements that perform specific tasks. There are three types of functions: built-in functions, module functions, and user-defined functions. Built-in functions are predefined in Python, module functions are contained in .py files, and user-defined functions are created by the user. The document provides examples of various types of functions and how they can be called and used.
Kunal Chauhan will be conducting a 6 week Python training program from May 15th to June 26th. The training will cover introductory Python programming, basics of programming in Python including variables, data types, operators, and control flow, principles of object-oriented programming, SQLite database usage, GUI development with PyQt, and applications of Python in various disciplines like web development, machine learning, data science, and more.
1. The document discusses Python arrays, modules, and packages. It describes how to create and access elements of an array, as well as common array methods.
2. It explains what modules are and how to create, import, rename, and access attributes of modules. Dir() function and module search path are also covered.
3. Python packages and subpackages are defined. Steps to create packages and import from packages and subpackages are provided along with an example.
This document is a summer training report submitted by Shubham Yadav to the Department of Information Technology at Rajkiya Engineering College. The report details Shubham's 4-week training program at IQRA Software Technologies where he learned about Python programming language and its libraries like NumPy, Matplotlib, Pandas, and OpenCV. The report includes sections on the history of Python, its characteristics, data structures in Python, file handling, and how to use various Python libraries for tasks like mathematical operations, data visualization, data analysis, and computer vision.
Python is an interpreted, object-oriented programming language that uses indentation to identify blocks of code. It is dynamically typed and strongly typed, with objects determining types at runtime rather than requiring explicit type declaration. Common data types include mutable types like lists and dictionaries as well as immutable types like strings and tuples.
The document discusses Python interview questions and answers related to Python fundamentals like data types, variables, functions, objects and classes. Some key points include:
- Python is an interpreted, interactive and object-oriented programming language. It uses indentation to identify code blocks rather than brackets.
- Python supports dynamic typing where the type is determined at runtime. It is strongly typed meaning operations inappropriate for a type will fail with an exception.
- Common data types include lists (mutable), tuples (immutable), dictionaries, strings and numbers.
- Functions use def, parameters are passed by reference, and variables can be local or global scope.
- Classes use inheritance, polymorphism and encapsulation to create
This document provides an overview of Python basics for data analysis, including introductions to key Python packages like NumPy, Pandas, and Matplotlib. It covers fundamental Python concepts like data types, operators, conditional statements, loops and functions. It also demonstrates how to load and manipulate data with NumPy arrays and Pandas DataFrames, including indexing, slicing, grouping, merging, and handling missing values. Visualization with Matplotlib charts is also covered.
Chapter Functions for grade 12 computer ScienceKrithikaTM
1. A function is a block of code that performs a specific task and can be called anywhere in a program. Functions make code reusable, improve modularity, and make programs easier to understand.
2. There are three main types of functions: built-in functions, functions defined in modules, and user-defined functions. Built-in functions are pre-defined and always available, module functions require importing, and user-defined functions are created by programmers.
3. Functions improve code organization and readability by separating code into logical, modular units. Functions can take parameters, return values, and be called from other parts of a program or other functions. This allows for code reuse and modular programming.
This document provides an overview of Java utilities and collection classes. It discusses the Java Math class and methods for numeric operations. It also describes wrapper classes for primitive data types and lists the eight primitive types in Java. Finally, it provides an example of using the Collections class to sort, reverse, shuffle a list and check element frequencies.
A for loop is probably the most common type of loop in Python. A for loop will select items from any iterable. In Python an iterable is any container (list, tuple, set, dictionary), as well as many other important objects such as generator function, generator expressions, the results of builtin functions such as filter, map, range and many other items.
The document provides an introduction to the Python programming language. It discusses what Python is, its creator Guido van Rossum, and how to write a simple "Hello World" program. It also covers Python data types, operators, flow control using conditionals and loops, functions, input/output operations, and the Zen of Python philosophy guiding Python's design. The document serves as the first day of instruction in a Python course.
This document discusses Python libraries, including popular libraries for data analysis, web development, and machine learning. It provides examples of how to use the Matplotlib and NumPy libraries, describing their features and sample code. The key steps to install and import Python libraries using pip and import statements are also outlined. Overall, the document introduces several essential Python libraries and their applications.
The document provides information about various Python concepts like PEP 8, pickling, lambda functions, generators, modules, packages and more. It also includes questions about memory management in Python, tools for static analysis, decorators, iterators, slicing, and other common Python interview questions.
This document discusses functions in Python. It begins by defining what a function is and provides examples of built-in functions and functions defined in modules. It then lists some advantages of using functions such as code reusability and readability. The document discusses the different types of functions - built-in functions, functions defined in modules, and user-defined functions. It provides examples of each type. The document also covers topics such as function parameters, return values, variable scope, lambda functions, and using functions from libraries.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
Implementing ELDs or Electronic Logging Devices is slowly but surely becoming the norm in fleet management. Why? Well, integrating ELDs and associated connected vehicle solutions like fleet tracking devices lets businesses and their in-house fleet managers reap several benefits. Check out the post below to learn more.
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitForth
Vanessa Warheit, Co-Founder of EV Charging for All, gave this presentation at the Forth Addressing The Challenges of Charging at Multi-Family Housing webinar on June 11, 2024.
Understanding Catalytic Converter Theft:
What is a Catalytic Converter?: Learn about the function of catalytic converters in vehicles and why they are targeted by thieves.
Why are They Stolen?: Discover the valuable metals inside catalytic converters (such as platinum, palladium, and rhodium) that make them attractive to criminals.
Steps to Prevent Catalytic Converter Theft:
Parking Strategies: Tips on where and how to park your vehicle to reduce the risk of theft, such as parking in well-lit areas or secure garages.
Protective Devices: Overview of various anti-theft devices available, including catalytic converter locks, shields, and alarms.
Etching and Marking: The benefits of etching your vehicle’s VIN on the catalytic converter or using a catalytic converter marking kit to make it traceable and less appealing to thieves.
Surveillance and Monitoring: Recommendations for using security cameras and motion-sensor lights to deter thieves.
Statistics and Insights:
Theft Rates by Borough: Analysis of data to determine which borough in NYC experiences the highest rate of catalytic converter thefts.
Recent Trends: Current trends and patterns in catalytic converter thefts to help you stay aware of emerging hotspots and tactics used by thieves.
Benefits of This Presentation:
Awareness: Increase your awareness about catalytic converter theft and its impact on vehicle owners.
Practical Tips: Gain actionable insights and tips to effectively prevent catalytic converter theft.
Local Insights: Understand the specific risks in different NYC boroughs, helping you take targeted preventive measures.
This presentation aims to equip you with the knowledge and tools needed to protect your vehicle from catalytic converter theft, ensuring you are prepared and proactive in safeguarding your property.
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinForth
Cat Plein, Development & Communications Director of Forth, gave this presentation at the Forth and Electrification Coalition CFI Grant Program - Overview and Technical Assistance webinar on June 12, 2024.
EV Charging at MFH Properties by Whitaker JamiesonForth
Whitaker Jamieson, Senior Specialist at Forth, gave this presentation at the Forth Addressing The Challenges of Charging at Multi-Family Housing webinar on June 11, 2024.
Welcome to ASP Cranes, your trusted partner for crane solutions in Raipur, Chhattisgarh! With years of experience and a commitment to excellence, we offer a comprehensive range of crane services tailored to meet your lifting and material handling needs.
At ASP Cranes, we understand the importance of reliable and efficient crane operations in various industries, from construction and manufacturing to logistics and infrastructure development. That's why we strive to deliver top-notch solutions that enhance productivity, safety, and cost-effectiveness for our clients.
Our services include:
Crane Rental: Whether you need a crawler crane for heavy lifting or a hydraulic crane for versatile operations, we have a diverse fleet of well-maintained cranes available for rent. Our rental options are flexible and can be customized to suit your project requirements.
Crane Sales: Looking to invest in a crane for your business? We offer a wide selection of new and used cranes from leading manufacturers, ensuring you find the perfect equipment to match your needs and budget.
Crane Maintenance and Repair: To ensure optimal performance and safety, regular maintenance and timely repairs are essential for cranes. Our team of skilled technicians provides comprehensive maintenance and repair services to keep your equipment running smoothly and minimize downtime.
Crane Operator Training: Proper training is crucial for safe and efficient crane operation. We offer specialized training programs conducted by certified instructors to equip operators with the skills and knowledge they need to handle cranes effectively.
Custom Solutions: We understand that every project is unique, which is why we offer custom crane solutions tailored to your specific requirements. Whether you need modifications, attachments, or specialized equipment, we can design and implement solutions that meet your needs.
At ASP Cranes, customer satisfaction is our top priority. We are dedicated to delivering reliable, cost-effective, and innovative crane solutions that exceed expectations. Contact us today to learn more about our services and how we can support your project in Raipur, Chhattisgarh, and beyond. Let ASP Cranes be your trusted partner for all your crane needs!
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinForth
Brandt Hertenstein, Program Manager of the Electrification Coalition gave this presentation at the Forth and Electrification Coalition CFI Grant Program - Overview and Technical Assistance webinar on June 12, 2024.
Charging Fueling & Infrastructure (CFI) Program by Kevin MillerForth
Kevin Miller, Senior Advisor, Business Models of the Joint Office of Energy and Transportation gave this presentation at the Forth and Electrification Coalition CFI Grant Program - Overview and Technical Assistance webinar on June 12, 2024.
2. 1. Python Standard Library:
math module: for mathematical functions
cmath module:- mathematical functions for complex numbers.
random module :- functions for generating pseudo- random
numbers.
string module: for string/text-related functions.
USING PYTHON STANDARD LIBRARY’S FUNCTIONS AND MODULES
Python’s standard library is very extensive, offering a wide range of modules
and functions. The library contains built-in modules (written in C) that provide
access to system functionality such as file I/O, that would otherwise be
inaccessible to Python programmers, as well as modules written in Python
that provide standardized solutions for many problems that occur in everyday
programming. Some of these important modules are explicitly designed to
encourage and enhance the portability of Python programs.
3. 2. NumPy Library- NumPy is the fundamental package for scientific
computing and manipulate numeric array with Python.
3. SciPy Library(pronounced “Sigh Pie”) is a Python-based ecosystem
of open-source software for mathematics, science, and engineering.
4. Tkinter Library :Tkinter is actually an inbuilt Python module
used to create simple GUI apps. It is the most commonly used
module for GUI apps in the Python.
5. Matplotlib Library: Matplotlib is one of the most popular Python
packages used for data visualization. It is a cross-platform library
for making 2D plots from data in arrays.
4. Processing of import <module> command
1.Imported module’s code gets executed after interpretation.
2.All the programs and variables of imported module are present in the program.
Python import statement
import math
print(“2 to the power 3 is ", math.pow(2,3))
Import with renaming
import math as mt
print(“2 to the power 3 is ", mt.pow(2,3))
Processing of from <module> import <object> command
1.Imported module’s code gets executed after interpretation.
2.Only asked programs and variables of imported module are present in the program.
Python from...import statement
from math import pow
print(“2 to the power 3 is ", pow(2,3))
Import all names
from math import *
print(“2 to the power 3 is ", pow(2,3))
5. Python - Math Module
We have already discussed major functions using math module. Python
provides many other mathematical built-in functions as well. These include
trigonometric functions, representation functions, logarithmic functions, angle
conversion functions, etc. In addition, two mathematical constants are also
defined in this module.
Pie (π) is a well-known mathematical constant, which is defined as the ratio of the circumference
to the diameter of a circle and its value is 3.141592653589793.
import math
math.pi
3.141592653589793
from math import pi
print(pi)
3.141592653589793
or
Another well-known mathematical constant defined in the math module is e. It is called Euler's
number and it is a base of the natural logarithm. Its value is 2.718281828459045.
math.e
2.718281828459045
6. The math module presents two angle conversion functions: degrees() and radians()
, to convert the angle from degrees to radians and vice versa.
For example, the following statements convert the angle of 30 degrees to radians
and back.
math.radians(30)
0.5235987755982988
math.degrees(math.pi/6)
29.999999999999996
math.log()
The math.log() method returns the natural logarithm of a given number. The natural
logarithm is calculated to the base e.
math.log(10)
2.302585092994046
7. Python - Random Module
Functions in the random module depend on a pseudo-random number generator
function random(), which generates a random float number between 0.0 and 1.0.
random.random(): Generates a random float number between 0.0 to 1.0. The function doesn't
need any arguments.
import random
print(random.random())
random.randint(): Returns a random integer between the specified integers.
import random
print(random.randint(3, 9))
randrange() Method
import random
print(random.randrange(3, 90,2))
8. String Methods
Python has a set of built-in methods that you can use on strings.
Method Description
capitalize() Converts the first character to upper case
count() Returns the number of times a specified value occurs in a string
find() Searches the string for a specified value and returns the position of where it was
found
index() Searches the string for a specified value and returns the position of where it was
found
isalnum() Returns True if all characters in the string are alphanumeric
isalpha() Returns True if all characters in the string are in the alphabet
isdecimal() Returns True if all characters in the string are decimals
isdigit() Returns True if all characters in the string are digits
islower() Returns True if all characters in the string are lower case
isnumeric() Returns True if all characters in the string are numeric
isupper() Returns True if all characters in the string are upper case
lower() Converts a string into lower case
replace() Returns a string where a specified value is replaced with a specified value
split() Splits the string at the specified separator, and returns a list
9. Relation Between Python
Libraries, Module and
Package
•A module is a file containing
python definition, functions,
variables, classes and statements.
The extension of this file is “.py”.
•While Python package, is directory
(folder) of python modules.
•A library is collection of many
packages in python. Generally
there is no difference between
python package and python library.
10. Module in Python
•A module is a file containing python definition, functions, variables, classes and
statements. The extension of this file is “.py”.
Advantages–
–Its biggest advantage is that we can import its functionality in any program and
use it.
–Reusability is one of the biggest advantages.
–It helps in logically organization of Python code.
–Programming becomes very easy when we use the collection of same types of
codes.
–Categorization : same attributes can be stored in one module.
11.
12.
13. Namespaces in Python
•We imported a module in to a program which was referred as a namespace.
•To define a Namespace it is necessary to define its name.
•Python name is a kind of identifier which we use to access any python object. And in Python each and
everything is an object.
•Namespaces is used to separate the different sections of a program.
•Python has 3 types of namespaces -
–Global
–Local
–Built-in
Each module creates its own global namespace.
When we call a function then a local python namespace
is created where all the names of functions are exist.
14.
15.
16. PACKAGE / LIBRARY
•Python Package is the collection of same type of modules.
•You can use built in package as well as your own package.
•Python Package is a simple directory. Modules are stored in that directory.
•Package or library are generally same.
•Steps to make a package is as follows – (geometry)
1.We create a folder (directory) named geometry which will contain two files area.py
and volume.py
2.In the same directory we will put another file named “__init__.py”
3.__init__.py is necessary because this is the file which tells Python that directory is
package. And this file
initializes the package
4.Then we import the package and use the content.
17.
18. Standard Python Libraries
We have already discussed about math and string module. Same way we will
discuss two more important libraries. - datetime library or datetime module.
Python supports yyyy-mm-dd format for date. It has tow important classes -
–date class
today ( )
year( )
month ( )
day ( )
–time class
now ( )
hour ( )
minute ( )
second ( )