SlideShare a Scribd company logo
1 of 9
Welcome
to
Vibrant Technology & Computers
Best Training
Institute for
PYTHON
contents
 Variables and types
 Numeric expressions
 String conversions
 Objects, names and references
Variables and types
>>> a = 'Hello world!' # this is an assignment statement
>>> print a
'Hello world!'
>>> type(a) # expression: outputs the value in interactive mode
<type 'str'>
>>> n = 12
>>> print n
12
>>> type(n)
<type 'int'>
>>> n = 12.0
>>> type(n)
<type 'float'>
• Variables are created when they are assigned
• No declaration required
• The variable name is case sensitive: ‘val’ is not the same as ‘Val’
• The type of the variable is determined by Python
• A variable can be reassigned to whatever, whenever
>>> n = 'apa'
>>> print n
'apa'
>>> type(n)
<type 'str'>
Numeric expressions
• The usual numeric expression operators: +, -, /, *, **, %, //
• Precedence and parentheses work as expected
>>> 12+5
17
>>> 12+5*2
22
>>> (12+5)*2
34
• Full list on page 58 in ‘Learning Python’
>>> a=12+5
>>> print a
17
>>> b = 12.4 + a # 'a' converted to float automatically
>>> b # uses function 'repr'
29.399999999999999
>>> print b # uses function 'str'
29.4
>>> 4 + 5.5
9.5
>>> 1 + 3.0**2
10.0
>>> 1+2j + 3-4j
(4-2j)
String conversions
• Convert data types using functions ‘str’, ‘int’, ‘float’
• ‘repr’ is a variant of ‘str’
– intended for strict, code-like representation of values
– ‘str’ usually gives nicer-looking representation
• Function ‘eval’ interprets a string as a Python expression
>>> a = "58"
>>> type(a)
<type 'str'>
>>> b=int(a)
>>> b
58
>>> type(b)
<type 'int'>
>>> c = int('blah') # what happens when something illegal is done?
Traceback (most recent call last):
File "<pyshell#34>", line 1, in -toplevel-
c = int('blah')
ValueError: invalid literal for int(): blah
>>> f = float('1.2e-3')
>>> f # uses 'repr'
0.0011999999999999999
>>> print f # uses 'str'
0.0012
>>> eval('23-12')
11
Changing strings. Not!
• A string cannot be changed in Python! Immutable
• Good reasons for this; more later
• Create new strings from bits and pieces of old
>>> s[0] = 'B'
Traceback (most recent call last):
File "<pyshell#68>", line 1, in -toplevel-
s[0] = 'B'
TypeError: object doesn't support item assignment
>>> s = 'B' + s[1:]
>>> s
'Bart 1Part 1'
• Recreating strings may use a lot of computing power
• If you need to create many new strings, learn string formatting (more later)
• List processing can often be used to make string handling more efficient
Objects, names and references
• All values are objects
• A variable is a name referencing an object
• An object may have several names referencing it
• Important when modifying objects in-place!
• You may have to make proper copies to get the effect you want
• For immutable objects (numbers, strings), this is never a problem
a>>> a = [1, 3, 2]
>>> b = a
>>> c = b[0:2]
>>> d = b[:]
[1, 3, 2]
b
c
d
[1, 3]
[1, 3, 2]
>>> b.sort() # 'a' is affected!
>>> a
[1, 2, 3]
Thank You…

More Related Content

What's hot

The Ring programming language version 1.2 book - Part 10 of 84
The Ring programming language version 1.2 book - Part 10 of 84The Ring programming language version 1.2 book - Part 10 of 84
The Ring programming language version 1.2 book - Part 10 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84Mahmoud Samir Fayed
 
2.2 higher order-functions
2.2 higher order-functions2.2 higher order-functions
2.2 higher order-functionsfuturespective
 
The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184Mahmoud Samir Fayed
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixirbrien_wankel
 
Strings in C language
Strings in C languageStrings in C language
Strings in C languageP M Patil
 
The Ring programming language version 1.5.1 book - Part 17 of 180
The Ring programming language version 1.5.1 book - Part 17 of 180The Ring programming language version 1.5.1 book - Part 17 of 180
The Ring programming language version 1.5.1 book - Part 17 of 180Mahmoud Samir Fayed
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++NUST Stuff
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtendtakezoe
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basicsgourav kottawar
 
Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++NUST Stuff
 
C++ Secure Programming
C++ Secure ProgrammingC++ Secure Programming
C++ Secure ProgrammingMarian Marinov
 
F# Presentation
F# PresentationF# Presentation
F# Presentationmrkurt
 
C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3Ammara Javed
 

What's hot (19)

The Ring programming language version 1.2 book - Part 10 of 84
The Ring programming language version 1.2 book - Part 10 of 84The Ring programming language version 1.2 book - Part 10 of 84
The Ring programming language version 1.2 book - Part 10 of 84
 
The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84
 
2.2 higher order-functions
2.2 higher order-functions2.2 higher order-functions
2.2 higher order-functions
 
The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184
 
constructors
constructorsconstructors
constructors
 
Python intro
Python introPython intro
Python intro
 
Python study material
Python study materialPython study material
Python study material
 
Python course
Python coursePython course
Python course
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
The Ring programming language version 1.5.1 book - Part 17 of 180
The Ring programming language version 1.5.1 book - Part 17 of 180The Ring programming language version 1.5.1 book - Part 17 of 180
The Ring programming language version 1.5.1 book - Part 17 of 180
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++
 
Composite types
Composite typesComposite types
Composite types
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtend
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basics
 
Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++
 
C++ Secure Programming
C++ Secure ProgrammingC++ Secure Programming
C++ Secure Programming
 
F# Presentation
F# PresentationF# Presentation
F# Presentation
 
C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3
 

Viewers also liked

شهادة الهيئة السعودية
شهادة الهيئة السعوديةشهادة الهيئة السعودية
شهادة الهيئة السعوديةwael salim
 
Sequence Semantics for Norms and Obligations
Sequence Semantics for Norms and ObligationsSequence Semantics for Norms and Obligations
Sequence Semantics for Norms and ObligationsGuido Governatori
 
Informational books
Informational booksInformational books
Informational booksandrea7411
 
Librarian's desk
Librarian's deskLibrarian's desk
Librarian's deskandrea7411
 
Veilig gebruik van Social Media
Veilig gebruik van Social MediaVeilig gebruik van Social Media
Veilig gebruik van Social MediaFabian Spierings
 
The Journey to Business Process Compliance. Are We There Yet?
The Journey to Business Process Compliance. Are We There Yet?The Journey to Business Process Compliance. Are We There Yet?
The Journey to Business Process Compliance. Are We There Yet?Guido Governatori
 
понятия и концепты о данных и о базах данных
понятия и концепты о данных и о базах данныхпонятия и концепты о данных и о базах данных
понятия и концепты о данных и о базах данныхColegiul de Industrie Usoara
 

Viewers also liked (10)

شهادة الهيئة السعودية
شهادة الهيئة السعوديةشهادة الهيئة السعودية
شهادة الهيئة السعودية
 
Sequence Semantics for Norms and Obligations
Sequence Semantics for Norms and ObligationsSequence Semantics for Norms and Obligations
Sequence Semantics for Norms and Obligations
 
Age
AgeAge
Age
 
Informational books
Informational booksInformational books
Informational books
 
Librarian's desk
Librarian's deskLibrarian's desk
Librarian's desk
 
Veilig gebruik van Social Media
Veilig gebruik van Social MediaVeilig gebruik van Social Media
Veilig gebruik van Social Media
 
The Journey to Business Process Compliance. Are We There Yet?
The Journey to Business Process Compliance. Are We There Yet?The Journey to Business Process Compliance. Are We There Yet?
The Journey to Business Process Compliance. Are We There Yet?
 
понятия и концепты о данных и о базах данных
понятия и концепты о данных и о базах данныхпонятия и концепты о данных и о базах данных
понятия и концепты о данных и о базах данных
 
Modelarea și tehnologia tricotajelor
Modelarea și tehnologia tricotajelor Modelarea și tehnologia tricotajelor
Modelarea și tehnologia tricotajelor
 
950 g
950 g950 g
950 g
 

Similar to Best Python Training Institute for Learning Variables, Strings, Numbers and References

Python course in_mumbai
Python course in_mumbaiPython course in_mumbai
Python course in_mumbaivibrantuser
 
Python course in_mumbai
Python course in_mumbaiPython course in_mumbai
Python course in_mumbaivibrantuser
 
Learning python
Learning pythonLearning python
Learning pythonFraboni Ec
 
Learning python
Learning pythonLearning python
Learning pythonJames Wong
 
Function in Python [Autosaved].ppt
Function in Python [Autosaved].pptFunction in Python [Autosaved].ppt
Function in Python [Autosaved].pptGaganvirKaur
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsYashJain47002
 
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90minsLarry Cai
 
Chapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxChapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxSovannDoeur
 

Similar to Best Python Training Institute for Learning Variables, Strings, Numbers and References (20)

Python course in_mumbai
Python course in_mumbaiPython course in_mumbai
Python course in_mumbai
 
Python course in_mumbai
Python course in_mumbaiPython course in_mumbai
Python course in_mumbai
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Python String Revisited.pptx
Python String Revisited.pptxPython String Revisited.pptx
Python String Revisited.pptx
 
PYTHON
PYTHONPYTHON
PYTHON
 
Function in Python [Autosaved].ppt
Function in Python [Autosaved].pptFunction in Python [Autosaved].ppt
Function in Python [Autosaved].ppt
 
Python material
Python materialPython material
Python material
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
 
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
Chapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxChapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptx
 

More from Vibrant Technologies & Computers

Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Vibrant Technologies & Computers
 

More from Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Best Python Training Institute for Learning Variables, Strings, Numbers and References

  • 3. contents  Variables and types  Numeric expressions  String conversions  Objects, names and references
  • 4. Variables and types >>> a = 'Hello world!' # this is an assignment statement >>> print a 'Hello world!' >>> type(a) # expression: outputs the value in interactive mode <type 'str'> >>> n = 12 >>> print n 12 >>> type(n) <type 'int'> >>> n = 12.0 >>> type(n) <type 'float'> • Variables are created when they are assigned • No declaration required • The variable name is case sensitive: ‘val’ is not the same as ‘Val’ • The type of the variable is determined by Python • A variable can be reassigned to whatever, whenever >>> n = 'apa' >>> print n 'apa' >>> type(n) <type 'str'>
  • 5. Numeric expressions • The usual numeric expression operators: +, -, /, *, **, %, // • Precedence and parentheses work as expected >>> 12+5 17 >>> 12+5*2 22 >>> (12+5)*2 34 • Full list on page 58 in ‘Learning Python’ >>> a=12+5 >>> print a 17 >>> b = 12.4 + a # 'a' converted to float automatically >>> b # uses function 'repr' 29.399999999999999 >>> print b # uses function 'str' 29.4 >>> 4 + 5.5 9.5 >>> 1 + 3.0**2 10.0 >>> 1+2j + 3-4j (4-2j)
  • 6. String conversions • Convert data types using functions ‘str’, ‘int’, ‘float’ • ‘repr’ is a variant of ‘str’ – intended for strict, code-like representation of values – ‘str’ usually gives nicer-looking representation • Function ‘eval’ interprets a string as a Python expression >>> a = "58" >>> type(a) <type 'str'> >>> b=int(a) >>> b 58 >>> type(b) <type 'int'> >>> c = int('blah') # what happens when something illegal is done? Traceback (most recent call last): File "<pyshell#34>", line 1, in -toplevel- c = int('blah') ValueError: invalid literal for int(): blah >>> f = float('1.2e-3') >>> f # uses 'repr' 0.0011999999999999999 >>> print f # uses 'str' 0.0012 >>> eval('23-12') 11
  • 7. Changing strings. Not! • A string cannot be changed in Python! Immutable • Good reasons for this; more later • Create new strings from bits and pieces of old >>> s[0] = 'B' Traceback (most recent call last): File "<pyshell#68>", line 1, in -toplevel- s[0] = 'B' TypeError: object doesn't support item assignment >>> s = 'B' + s[1:] >>> s 'Bart 1Part 1' • Recreating strings may use a lot of computing power • If you need to create many new strings, learn string formatting (more later) • List processing can often be used to make string handling more efficient
  • 8. Objects, names and references • All values are objects • A variable is a name referencing an object • An object may have several names referencing it • Important when modifying objects in-place! • You may have to make proper copies to get the effect you want • For immutable objects (numbers, strings), this is never a problem a>>> a = [1, 3, 2] >>> b = a >>> c = b[0:2] >>> d = b[:] [1, 3, 2] b c d [1, 3] [1, 3, 2] >>> b.sort() # 'a' is affected! >>> a [1, 2, 3]