Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly readable using English keywords. Python is interpreted at runtime and does not require compilation. It supports both procedural and object-oriented programming. Python is beginner friendly and supports a wide range of applications. It is portable, extensible, and has a large standard library. Variables are dynamically typed and support integers, floating point numbers, complex numbers, strings, lists, tuples and dictionaries.
Python was created in the late 1980s by Guido van Rossum. It draws influence from many other languages like ABC, Modula-3, C, C++, Algol68, SmallTalk, and Unix shell scripting languages. Python is an interpreted, interactive, object-oriented scripting language that is highly readable and easy to maintain. It has a large standard library and supports features like being interactive, object-oriented programming, databases, GUI programming, and is portable across platforms.
This document provides an overview of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented language and was created by Guido van Rossum. It then covers getting and installing Python, writing basic Python programs, variables and data types, operators, control flow statements like if/else, and other core concepts like functions, modules, and exceptions.
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
Python strings are sequences of characters that can be accessed and manipulated using various string methods. Strings can be declared using either single or double quotes and support escape characters. Strings are immutable and concatenation creates a new string. Common string methods include len() to get the length, lower()/upper() to case conversion, strip() to remove whitespace, and startswith()/endswith() to check substrings.
Python is an interpreted, interactive, object-oriented programming language. It has a simple syntax and is used for rapid application development. Python supports procedural, object-oriented, and functional programming. It has a large standard library and can connect to existing components. Python is easy to read and maintain due to its clear syntax and structure. It is also portable and has broad library support.
This document provides an introduction to Python programming. It discusses the history and origins of Python, why it is useful for programming, its core features like object-oriented programming and indentation, basic syntax like variables, data types, and keywords. It also covers strings, booleans, and how to assign values and combine text in strings.
This document provides an overview of Python programming concepts across 5 units. Unit 1 introduces Python installation, data types, variables, expressions, statements and functions. It covers integers, floats, Booleans, strings, lists and the basics of writing Python code. Unit 2 discusses control flow statements like conditionals and loops. Unit 3 covers functions, strings, arrays and lists in more detail. Unit 4 focuses on lists, tuples, dictionaries and their methods. Unit 5 discusses files, exceptions, modules and packages in Python.
This document provides an introduction to the Python programming language. It defines Python as a high-level, general-purpose and interpreted programming language. It then discusses that Python is easy to learn, can be used for a wide range of applications, and code is interpreted line by line at runtime. The document also covers why Python is a useful language due to its productivity, popularity within industries, ease of learning, large ecosystem of libraries, and ability to run on multiple platforms. It concludes by explaining basic Python concepts like variables, strings, numbers and data types.
This document provides an overview of Python programming in Katana for beginners. It discusses scripting languages and their advantages, different programming paradigms like procedural and object-oriented programming, and key Python concepts like data types, variables, functions, modules and packages. The document also demonstrates how to get started with Python in Katana, covering topics like syntax, comments, writing scripts and using the interactive console.
This document provides an introduction to the Python programming language. It discusses that Python was created in the late 1980s and features an easy to read syntax, is open source, cross-platform, interpreted, and object-oriented. It also covers installing Python, working in the IDLE integrated development environment and Jupyter notebooks, the differences between interactive and script modes, Python syntax including keywords, statements, indents, comments, variables, and input/output. The document aims to give readers an overview of the essential aspects of Python.
The document provides an overview of the Python programming language. It outlines the presentation which includes topics like Python overview, data types, control structures, input/output, functions, file handling, exceptions, modules, classes, examples comparing Python and Java, and useful tools. It then delves into more details on each of these topics, providing information on Python's history, versions, features, syntax, variables, statements, indentation and data types. It also discusses who uses Python and for what purposes.
The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
Python is one of the powerful, high-level, easy to learn programming language that
provides a huge number of applications. Some of its features, such as being object-oriented
and open source, having numerous IDE’s, etc. make it one of the most in-demand
programming languages of the present IT industry.
According to TIOBE index, as of January 2020, Python is one of the popular programming
languages. By looking at the popularity of this programming language, many IT
professionals, both beginners as well as experienced alike, are willing to build their career
as a Python developer
The type of a value refers to the kind of data it represents. In Python, the main types are:
- int - integer numbers like 1, 2, 100
- float - floating point numbers like 1.5, 3.14159
- str - strings, sequences of characters like 'hello'
- bool - boolean values True or False
When you write code, Python assigns a type to each value. The type determines how it can be used and what operations are valid on it. For example, you can add two integers but not add an integer to a string. Checking and understanding types is important for writing correct Python code.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
Python is an interpreted, object-oriented programming language that can be used for many types of applications. It was created by Guido van Rossum in the 1980s and takes influence from languages like ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell scripting. Python code can be written and executed with either an interactive interpreter or scripts, and Python is widely used for web development, data analysis, artificial intelligence, and scientific computing.
Python is a popular, high-level programming language used for web development, software development, data science, and more. It can be used to build both simple scripting programs as well as large-scale applications. Key characteristics of Python include being dynamically typed, having automatic memory management, and using indentation to define code blocks rather than curly braces. Python supports procedural, object-oriented, and functional programming styles and has a large standard library.
This document provides an overview of the Python programming language. It discusses that Python is an interpreted, high-level, general-purpose programming language created by Guido van Rossum in 1991. It is commonly used for web development, software development, data science, and more. The document then covers Python syntax, basic programming concepts like variables and data types, and how to set up a Python environment and write simple Python programs.
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
This document provides an introduction to Python programming. It discusses the history and origins of Python, why it is useful for programming, its core features like object-oriented programming and indentation, basic syntax like variables, data types, and keywords. It also covers strings, booleans, and how to assign values and combine text in strings.
This document provides an overview of Python programming concepts across 5 units. Unit 1 introduces Python installation, data types, variables, expressions, statements and functions. It covers integers, floats, Booleans, strings, lists and the basics of writing Python code. Unit 2 discusses control flow statements like conditionals and loops. Unit 3 covers functions, strings, arrays and lists in more detail. Unit 4 focuses on lists, tuples, dictionaries and their methods. Unit 5 discusses files, exceptions, modules and packages in Python.
This document provides an introduction to the Python programming language. It defines Python as a high-level, general-purpose and interpreted programming language. It then discusses that Python is easy to learn, can be used for a wide range of applications, and code is interpreted line by line at runtime. The document also covers why Python is a useful language due to its productivity, popularity within industries, ease of learning, large ecosystem of libraries, and ability to run on multiple platforms. It concludes by explaining basic Python concepts like variables, strings, numbers and data types.
This document provides an overview of Python programming in Katana for beginners. It discusses scripting languages and their advantages, different programming paradigms like procedural and object-oriented programming, and key Python concepts like data types, variables, functions, modules and packages. The document also demonstrates how to get started with Python in Katana, covering topics like syntax, comments, writing scripts and using the interactive console.
This document provides an introduction to the Python programming language. It discusses that Python was created in the late 1980s and features an easy to read syntax, is open source, cross-platform, interpreted, and object-oriented. It also covers installing Python, working in the IDLE integrated development environment and Jupyter notebooks, the differences between interactive and script modes, Python syntax including keywords, statements, indents, comments, variables, and input/output. The document aims to give readers an overview of the essential aspects of Python.
The document provides an overview of the Python programming language. It outlines the presentation which includes topics like Python overview, data types, control structures, input/output, functions, file handling, exceptions, modules, classes, examples comparing Python and Java, and useful tools. It then delves into more details on each of these topics, providing information on Python's history, versions, features, syntax, variables, statements, indentation and data types. It also discusses who uses Python and for what purposes.
The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
Python is one of the powerful, high-level, easy to learn programming language that
provides a huge number of applications. Some of its features, such as being object-oriented
and open source, having numerous IDE’s, etc. make it one of the most in-demand
programming languages of the present IT industry.
According to TIOBE index, as of January 2020, Python is one of the popular programming
languages. By looking at the popularity of this programming language, many IT
professionals, both beginners as well as experienced alike, are willing to build their career
as a Python developer
The type of a value refers to the kind of data it represents. In Python, the main types are:
- int - integer numbers like 1, 2, 100
- float - floating point numbers like 1.5, 3.14159
- str - strings, sequences of characters like 'hello'
- bool - boolean values True or False
When you write code, Python assigns a type to each value. The type determines how it can be used and what operations are valid on it. For example, you can add two integers but not add an integer to a string. Checking and understanding types is important for writing correct Python code.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
Python is an interpreted, object-oriented programming language that can be used for many types of applications. It was created by Guido van Rossum in the 1980s and takes influence from languages like ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell scripting. Python code can be written and executed with either an interactive interpreter or scripts, and Python is widely used for web development, data analysis, artificial intelligence, and scientific computing.
Python is a popular, high-level programming language used for web development, software development, data science, and more. It can be used to build both simple scripting programs as well as large-scale applications. Key characteristics of Python include being dynamically typed, having automatic memory management, and using indentation to define code blocks rather than curly braces. Python supports procedural, object-oriented, and functional programming styles and has a large standard library.
This document provides an overview of the Python programming language. It discusses that Python is an interpreted, high-level, general-purpose programming language created by Guido van Rossum in 1991. It is commonly used for web development, software development, data science, and more. The document then covers Python syntax, basic programming concepts like variables and data types, and how to set up a Python environment and write simple Python programs.
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
Jeremy Millul - A Talented Software DeveloperJeremy Millul
Jeremy Millul is a talented software developer based in NYC, known for leading impactful projects such as a Community Engagement Platform and a Hiking Trail Finder. Using React, MongoDB, and geolocation tools, Jeremy delivers intuitive applications that foster engagement and usability. A graduate of NYU’s Computer Science program, he brings creativity and technical expertise to every project, ensuring seamless user experiences and meaningful results in software development.
AI Creative Generates You Passive Income Like Never BeforeSivaRajan47
For years, building passive income meant traditional routes—stocks, real estate, or
online businesses that required endless hours of setup and maintenance. But now,
Artificial Intelligence (AI) is redefining the landscape. We’re no longer talking about
automation in the background; we’re entering a world where AI creatives actively
design, produce, and monetize content and products, opening the floodgates for
passive income like never before.
Imagine AI tools writing books, designing logos, building apps, editing videos, creating
music, and even selling your digital products 24/7—without you lifting a finger after
setup. This isn't the future. It’s happening right now. And if you act fast, you can ride
the wave before it becomes saturated.
In this in-depth guide, we’ll show you how to tap into AI creativity for real, sustainable,
passive income streams—no fluff, no generic tips—just actionable, traffic-driving
insights.
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....Jasper Oosterveld
Sensitivity labels, powered by Microsoft Purview Information Protection, serve as the foundation for classifying and protecting your sensitive data within Microsoft 365. Their importance extends beyond classification and play a crucial role in enforcing governance policies across your Microsoft 365 environment. Join me, a Data Security Consultant and Microsoft MVP, as I share practical tips and tricks to get the full potential of sensitivity labels. I discuss sensitive information types, automatic labeling, and seamless integration with Data Loss Prevention, Teams Premium, and Microsoft 365 Copilot.
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfRejig Digital
Unlock the future of oil & gas safety with advanced environmental detection technologies that transform hazard monitoring and risk management. This presentation explores cutting-edge innovations that enhance workplace safety, protect critical assets, and ensure regulatory compliance in high-risk environments.
🔍 What You’ll Learn:
✅ How advanced sensors detect environmental threats in real-time for proactive hazard prevention
🔧 Integration of IoT and AI to enable rapid response and minimize incident impact
📡 Enhancing workforce protection through continuous monitoring and data-driven safety protocols
💡 Case studies highlighting successful deployment of environmental detection systems in oil & gas operations
Ideal for safety managers, operations leaders, and technology innovators in the oil & gas industry, this presentation offers practical insights and strategies to revolutionize safety standards and boost operational resilience.
👉 Learn more: https://www.rejigdigital.com/blog/continuous-monitoring-prevent-blowouts-well-control-issues/
Data Virtualization: Bringing the Power of FME to Any ApplicationSafe Software
Imagine building web applications or dashboards on top of all your systems. With FME’s new Data Virtualization feature, you can deliver the full CRUD (create, read, update, and delete) capabilities on top of all your data that exploit the full power of FME’s all data, any AI capabilities. Data Virtualization enables you to build OpenAPI compliant API endpoints using FME Form’s no-code development platform.
In this webinar, you’ll see how easy it is to turn complex data into real-time, usable REST API based services. We’ll walk through a real example of building a map-based app using FME’s Data Virtualization, and show you how to get started in your own environment – no dev team required.
What you’ll take away:
-How to build live applications and dashboards with federated data
-Ways to control what’s exposed: filter, transform, and secure responses
-How to scale access with caching, asynchronous web call support, with API endpoint level security.
-Where this fits in your stack: from web apps, to AI, to automation
Whether you’re building internal tools, public portals, or powering automation – this webinar is your starting point to real-time data delivery.
Improving Developer Productivity With DORA, SPACE, and DevExJustin Reock
Ready to measure and improve developer productivity in your organization?
Join Justin Reock, Deputy CTO at DX, for an interactive session where you'll learn actionable strategies to measure and increase engineering performance.
Leave this session equipped with a comprehensive understanding of developer productivity and a roadmap to create a high-performing engineering team in your company.
Create Your First AI Agent with UiPath Agent BuilderDianaGray10
Join us for an exciting virtual event where you'll learn how to create your first AI Agent using UiPath Agent Builder. This session will cover everything you need to know about what an agent is and how easy it is to create one using the powerful AI-driven UiPath platform. You'll also discover the steps to successfully publish your AI agent. This is a wonderful opportunity for beginners and enthusiasts to gain hands-on insights and kickstart their journey in AI-powered automation.
Developing Schemas with FME and Excel - Peak of Data & AI 2025Safe Software
When working with other team members who may not know the Esri GIS platform or may not be database professionals; discussing schema development or changes can be difficult. I have been using Excel to help illustrate and discuss schema design/changes during meetings and it has proven a useful tool to help illustrate how a schema will be built. With just a few extra columns, that Excel file can be sent to FME to create new feature classes/tables. This presentation will go thru the steps needed to accomplish this task and provide some lessons learned and tips/tricks that I use to speed the process.
In this talk, Elliott explores how developers can embrace AI not as a threat, but as a collaborative partner.
We’ll examine the shift from routine coding to creative leadership, highlighting the new developer superpowers of vision, integration, and innovation.
We'll touch on security, legacy code, and the future of democratized development.
Whether you're AI-curious or already a prompt engineering, this session will help you find your rhythm in the new dance of modern development.
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdfSOFTTECHHUB
I've tested over 50 AI coding tools in the past year, and I'm about to share the 25 that actually work. Not the ones with flashy marketing or VC backing – the ones that will make you code faster, smarter, and with way less frustration.
DevOps in the Modern Era - Thoughtfully Critical PodcastChris Wahl
https://youtu.be/735hP_01WV0
My journey through the world of DevOps! From the early days of breaking down silos between developers and operations to the current complexities of cloud-native environments. I'll talk about my personal experiences, the challenges we faced, and how the role of a DevOps engineer has evolved.
1. 1. Python Overview
• Python is a high-level, interpreted, interactive and object
oriented-scripting language.
• Python was designed to be highly readable which uses English
keywords frequently where as other languages use punctuation
and it has fewer syntactical constructions than other languages.
2. • Python is Interpreted: This means that it is processed at
runtime by the interpreter and you do not need to compile your
program before executing it. This is similar to PERL and PHP.
• Python is Interactive: This means that you can actually sit at a
Python prompt and interact with the interpreter directly to
write your programs.
• Python is Object-Oriented: This means that Python supports
Object-Oriented style or technique of programming that
encapsulates code within objects.
• Python is Beginner's Language: Python is a great language
for the beginner programmers and supports the development
of a wide range of applications, from simple text processing to
WWW browsers to games.
3. Compiling and interpreting
• Many languages require you to compile (translate) your
program into a form that the machine understands.
• Python is instead directly interpreted into machine instructions.
compile execute
output
source code
Hello.java
byte code
Hello.class
interpret
output
source code
Hello.py
4. History of Python:
• Python was developed by Guido van Rossum in the late eighties
and early nineties at the National Research Institute for
Mathematics and Computer Science in the Netherlands.
• Python is derived from many other languages, including ABC,
Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other
scripting languages.
• Python is copyrighted, Like Perl, Python source code is now
available under the GNU General Public License (GPL).
• Python is now maintained by a core development team at the
institute, although Guido van Rossum still holds a vital role in
directing it's progress.
5. Python Features
• Easy-to-learn: Python has relatively few keywords, simple
structure, and a clearly defined syntax.
• Easy-to-read: Python code is much more clearly defined and
visible to the eyes.
• Easy-to-maintain: Python's success is that its source code is
fairly easy-to-maintain.
• A broad standard library: One of Python's greatest strengths
is the bulk of the library is very portable and cross-platform
compatible on UNIX, Windows, and Macintosh.
• Interactive Mode: Support for an interactive mode in which
you can enter results from a terminal right to the language,
allowing interactive testing and debugging of snippets of code.
6. Python Features (cont’d)
• Portable: Python can run on a wide variety of hardware
platforms and has the same interface on all platforms.
• Extendable: You can add low-level modules to the Python
interpreter. These modules enable programmers to add to or
customize their tools to be more efficient.
• Databases: Python provides interfaces to all major commercial
databases.
• GUI Programming: Python supports GUI applications that can
be created and ported to many system calls, libraries, and
windows systems, such as Windows MFC, Macintosh, and the X
Window system of Unix.
• Scalable: Python provides a better structure and support for
large programs than shell scripting.
7. Python Environment
• Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX etc.)
• Win 9x/NT/2000
• Macintosh (PPC, 68K)
• OS/2
• DOS (multiple versions)
• PalmOS
• Nokia mobile phones
• Windows CE
• Acorn/RISC OS
• BeOS
• Amiga
• VMS/OpenVMS
• QNX
• VxWorks
• Psion
• Python has also been ported to the Java and .NET virtual machines.
9. • Script Mode Programming :
Invoking the interpreter with a script parameter begins
execution of the script and continues until the script is finished.
When the script is finished, the interpreter is no longer active.
For example, put the following in one test.py, and run,
print "Hello, Python!";
print "I love COMP3050!";
The output will be:
Hello, Python!
I love COMP3050!
10. Python Identifiers:
• A Python identifier is a name used to identify a variable,
function, class, module, or other object. An identifier starts with
a letter A to Z or a to z or an underscore (_) followed by zero or
more letters, underscores, and digits (0 to 9).
• Python does not allow punctuation characters such as @, $, and
% within identifiers. Python is a case sensitive programming
language. Thus Manpower and manpower are two different
identifiers in Python.
11. Python Identifiers (cont’d)
• Here are following identifier naming convention for Python:
– Class names start with an uppercase letter and all other
identifiers with a lowercase letter.
– Starting an identifier with a single leading underscore
indicates by convention that the identifier is meant to be
private.
– Starting an identifier with two leading underscores indicates
a strongly private identifier.
– If the identifier also ends with two trailing underscores, the
identifier is a language-defined special name.
12. Reserved Words:
and exec not
assert finally or
break for pass
class from print
continue global raise
def if return
del import try
elif in while
else is with
except lambda yield
Keywords contain lowercase letters only.
13. Lines and Indentation:
• One of the first caveats programmers encounter when learning
Python is the fact that there are no braces to indicate blocks of
code for class and function definitions or flow control. Blocks of
code are denoted by line indentation, which is rigidly enforced.
• The number of spaces in the indentation is variable, but all
statements within the block must be indented the same
amount. Both blocks in this example are fine:
if True:
print "Answer“;
print "True" ;
else:
print "Answer“;
print "False"
14. Multi-Line Statements:
• Statements in Python typically end with a new line. Python
does, however, allow the use of the line continuation character
() to denote that the line should continue. For example:
total = item_one +
item_two +
item_three
• Statements contained within the [], {}, or () brackets do not
need to use the line continuation character. For example:
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday']
15. Quotation in Python:
• Python accepts single ('), double (") and triple (''' or """) quotes
to denote string literals, as long as the same type of quote
starts and ends the string.
• The triple quotes can be used to span the string across multiple
lines. For example, all the following are legal:
word = 'word'
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is made up
of multiple lines and sentences."""
16. Comments in Python:
• A hash sign (#) that is not inside a string literal begins a
comment. All characters after the # and up to the physical line
end are part of the comment, and the Python interpreter
ignores them.
17. Using Blank Lines:
• A line containing only whitespace, possibly with a comment, is
known as a blank line, and Python totally ignores it.
• In an interactive interpreter session, you must enter an empty
physical line to terminate a multiline statement.
18. Multiple Statements on a Single Line:
• The semicolon ( ; ) allows multiple statements on the single line
given that neither statement starts a new code block. Here is a
sample snip using the semicolon:
import sys; x = 'foo'; sys.stdout.write(x + 'n')
19. Multiple Statement Groups as Suites:
• Groups of individual statements making up a single code block
are called suites in Python.
Compound or complex statements, such as if, while, def, and
class, are those which require a header line and a suite.
Header lines begin the statement (with the keyword) and
terminate with a colon ( : ) and are followed by one or more
lines which make up the suite.
if expression :
suite
elif expression :
suite
else :
suite
20. 3. Python - Variable Types
• Variables are nothing but reserved memory locations to store
values. This means that when you create a variable you reserve
some space in memory.
• Based on the data type of a variable, the interpreter allocates
memory and decides what can be stored in the reserved
memory. Therefore, by assigning different data types to
variables, you can store integers, decimals, or characters in
these variables.
21. Assigning Values to Variables:
• Python variables do not have to be explicitly declared to reserve
memory space. The declaration happens automatically when
you assign a value to a variable. The equal sign (=) is used to
assign values to variables.
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = "John" # A string
print counter
print miles
print name
22. Multiple Assignment:
• You can also assign a single value to several variables
simultaneously. For example:
a = b = c = 1
a, b, c = 1, 2, "john"
24. Python Numbers:
• Number data types store numeric values. They are immutable data
types, which means that changing the value of a number data type
results in a newly allocated object.
• Number objects are created when you assign a value to them. For
example:
var1 = 1
var2 = 10
Python supports four different numerical types:
• int (signed integers)
• long (long integers [can also be represented in octal and
hexadecimal])
• float (floating point real values)
• complex (complex numbers)
26. Python Strings:
• Strings in Python are identified as a contiguous set of
characters in between quotation marks.
• Python allows for either pairs of single or double quotes.
Subsets of strings can be taken using the slice operator ( [ ] and
[ : ] ) with indexes starting at 0 in the beginning of the string
and working their way from -1 at the end.
• The plus ( + ) sign is the string concatenation operator, and the
asterisk ( * ) is the repetition operator.
27. Example:
str = 'Hello World!'
print str # Prints complete string
print str[0] # Prints first character of the string
print str[2:5] # Prints characters starting from 3rd to 6th
print str[2:] # Prints string starting from 3rd character
print str * 2 # Prints string two times
print str + "TEST" # Prints concatenated string
Output:
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST
28. Python Lists:
• Lists are the most versatile of Python's compound data types. A
list contains items separated by commas and enclosed within
square brackets ([]).
• To some extent, lists are similar to arrays in C. One difference
between them is that all the items belonging to a list can be of
different data type.
• The values stored in a list can be accessed using the slice
operator ( [ ] and [ : ] ) with indexes starting at 0 in the
beginning of the list and working their way to end-1.
• The plus ( + ) sign is the list concatenation operator, and the
asterisk ( * ) is the repetition operator.
29. list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']
print list # Prints complete list
print list[0] # Prints first element of the list
print list[1:3] # Prints elements starting from 2nd till 3rd
print list[2:] # Prints elements starting from 3rd element
print tinylist * 2 # Prints list two times
print list + tinylist # Prints concatenated lists
Output:
['abcd', 786, 2.23, 'john', 70.2]
abcd
[786, 2.23]
[2.23, 'john', 70.2]
[123, 'john', 123, 'john']
['abcd', 786, 2.23, 'john', 70.2, 123, 'john']
30. Python Tuples:
• A tuple is another sequence data type that is similar to the list.
A tuple consists of a number of values separated by commas.
Unlike lists, however, tuples are enclosed within parentheses.
• The main differences between lists and tuples are: Lists are
enclosed in brackets ( [ ] ), and their elements and size can be
changed, while tuples are enclosed in parentheses ( ( ) ) and
cannot be updated. Tuples can be thought of as read-only lists.
31. tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print tuple # Prints complete list
print tuple[0] # Prints first element of the list
print tuple[1:3] # Prints elements starting from 2nd till 3rd
print tuple[2:] # Prints elements starting from 3rd element
print tinytuple * 2 # Prints list two times
print tuple + tinytuple # Prints concatenated lists
OUTPUT:
('abcd', 786, 2.23, 'john', 70.2)
abcd
(786, 2.23)
(2.23, 'john', 70.2)
(123, 'john', 123, 'john')
('abcd', 786, 2.23, 'john', 70.2, 123, 'john')
32. Python Dictionary:
• Python 's dictionaries are hash table type. They work like
associative arrays or hashes found in Perl and consist of key-
value pairs.
• Keys can be almost any Python type, but are usually numbers
or strings. Values, on the other hand, can be any arbitrary
Python object.
• Dictionaries are enclosed by curly braces ( { } ) and values can
be assigned and accessed using square braces ( [] ).
33. dict = {}
dict['one'] = "This is one"
dict[2] = "This is two“
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
print dict['one'] # Prints value for 'one' key
print dict[2] # Prints value for 2 key
print tinydict # Prints complete dictionary
print tinydict.keys() # Prints all the keys
print tinydict.values() # Prints all the values
OUTPUT:
This is one
This is two
{'dept': 'sales', 'code': 6734, 'name': 'john'}
['dept', 'code', 'name']
['sales', 6734, 'john']
34. Data Type Conversion:
Function Description
int(x [,base]) Converts x to an integer. base specifies the base if x is a string.
long(x [,base] ) Converts x to a long integer. base specifies the base if x is a
string.
float(x) Converts x to a floating-point number.
complex(real
[,imag])
Creates a complex number.
str(x) Converts object x to a string representation.
repr(x) Converts object x to an expression string.
eval(str) Evaluates a string and returns an object.
tuple(s) Converts s to a tuple.
list(s) Converts s to a list.
set(s) Converts s to a set.
dict(d) Creates a dictionary. d must be a sequence of (key,value) tuples.
frozenset(s) Converts s to a frozen set.
chr(x) Converts an integer to a character.
unichr(x) Converts an integer to a Unicode character.
ord(x) Converts a single character to its integer value.
hex(x) Converts an integer to a hexadecimal string.
oct(x) Converts an integer to an octal string.