SlideShare uma empresa Scribd logo
1 de 12
Variables and Statements
Variables
• A variable is a name that represents a value stored in the
computer’s memory.
• So far, applications that you have created have stored data only
in component properties.
• Variables are objects that can save data
temporarily to reuse & simplify code.
• Variable names should be descriptive of what
they are storing
• Variables allow to update and modify code more
efficiently
Variable Types
• Programming languages have a plethora of variable types, however…
• Scripting languages like Python have tried to streamline
these types to the bare bones essential categories.
• There is a default variable type in scripting languages,
string.
• However Python is smart enough to know what
information is stored in a variable and knows behaviors
associated with it. That way if you store a number in a
variable it will automatically convert it for you to that type.
• Question: What are some other types of data that we could store?
Declaring, Initializing & Assigning Variables
• Declaring a Variable : N/A in python
• Initializing a Variable : Creating a variable and setting a
starting value to a variable.
• Assigning/Reassigning a Variable : When we set a value to a
variable
Creating a Programming Statement
• A programming statement is a complete action comprised of
expressions.
• A mathematical equation
• Initializing a variable
• Assigning a variable to an LED
• Ex. red = LED(17)
• name = “Jason”
• age = 34
• lie = True
• money = math.floor(1.92)
Variable Output
• Question: What is the difference between this and printing strings?
Arithmetic Operators
Name Meaning Example Result
+ Addition 34 + 1 35
- Subtraction 34.0 – 0.1 33.9
* Multiplication 300 * 30 9000
/ Float Division 1 / 2 0.5
// Integer Division 1 // 2 0
** Exponentiation 4 ** 0.5 2.0
% Remainder 20 % 3 2
The Power of Remainders
• Question: What is the minimum number of coins to make $.97,
how did you come to this conclusion?
Saturday is the 6th
day in a week
A week has 7 days
After 10 days
The 2nd
day in a week is Tuesday
(6 + 10) % 7 is 2
124
3
12
0
73
2
6
1
268
3
24
2 Remainder
Quotient
2013
1
13
7
DividendDivisor
Arithmetic Expressions and Statements
is translated to
(3+4*x)/5 – 10*(y-5)*(a+b+c)/x + 9*(4/x + (9+x)/y)
)
94
(9
))(5(10
5
43
y
x
xx
cbayx 




Built in Math Functions
>>> max(2, 3, 4) # Returns a maximum number
4
>>> min(2, 3, 4) # Returns a minimum number
2
>>> round(3.51) # Rounds to its nearest integer
4
>>> round(3.4) # Rounds to its nearest integer
3
>>> abs(-3) # Returns the absolute value
3
>>> pow(2, 3) # Same as 2 ** 3
8
The Math Module
Function Description Example
fabs(x) Returns the absolute value of the argument. fabs(-2) is 2
ceil(x) Rounds x up to its nearest integer and ceil(2.1) is 3
returns this integer. ceil(-2.1) is -2
floor(x) Rounds x down to its nearest integer and floor(2.1) is 2
returns this integer. floor(-2.1) is -3
exp(x) Returns the exponential function of x (e^x). exp(1) is 2.71828
log(x) Returns the natural logarithm of x. log(2.71828) is 1.0
log(x, base) Returns the logarithm of x for the specified log10(10, 10) is 1
base.
sqrt(x) Returns the square root of x. sqrt(4.0) is 2
sin(x) Returns the sine of x. x represents an angle sin(3.14159 / 2) is 1
in radians. sin(3.14159) is 0
asin(x) Returns the angle in radians for the inverse asin(1.0) is 1.57
of sine. asin(0.5) is 0.523599
cos(x) Returns the cosine of x. x represents an cos(3.14159 / 2) is 0
angle in radians. cos(3.14159) is -1
acos(x) Returns the angle in radians for the inverse acos(1.0) is 0
of cosine. acos(0.5) is 1.0472
tan(x) Returns the tangent of x. x represents an tan(3.14159 / 4) is 1
angle in radians. tan(0.0) is 0
fmod(x, y) Returns the remainder of x/y as double. fmod(2.4, 1.3) is 1.1
degrees(x) Converts angle x from radians to degrees degrees(1.57) is 90
radians(x) Converts angle x from degrees to radians radians(90) is 1.57
Checkpoint
• 1. What is a variable?
• 2. Why do we have naming conventions?
• 3. What is the difference between a programming
expression and a statement?

Mais conteúdo relacionado

Mais procurados

C2 st lecture 4 handout
C2 st lecture 4 handoutC2 st lecture 4 handout
C2 st lecture 4 handoutfatima d
 
A study on number theory and its applications
A study on number theory and its applicationsA study on number theory and its applications
A study on number theory and its applicationsItishree Dash
 
C2 st lecture 3 handout
C2 st lecture 3 handoutC2 st lecture 3 handout
C2 st lecture 3 handoutfatima d
 
9.4 Cramer's Rule
9.4 Cramer's Rule9.4 Cramer's Rule
9.4 Cramer's Rulesmiller5
 
Dividing polynomials
Dividing polynomialsDividing polynomials
Dividing polynomialsEducación
 
C2 st lecture 8 pythagoras and trigonometry handout
C2 st lecture 8   pythagoras and trigonometry handoutC2 st lecture 8   pythagoras and trigonometry handout
C2 st lecture 8 pythagoras and trigonometry handoutfatima d
 
10th arithmetic progression solves questions
10th arithmetic progression solves questions10th arithmetic progression solves questions
10th arithmetic progression solves questionsAkshay Fegade
 
GCSE Foundation Maths
GCSE Foundation MathsGCSE Foundation Maths
GCSE Foundation MathsQwizdom UK
 
algebraic expression class VIII
algebraic expression class VIIIalgebraic expression class VIII
algebraic expression class VIIIHimani Priya
 
The binomial expansion
The binomial expansionThe binomial expansion
The binomial expansionJJkedst
 
Solution of matlab chapter 2
Solution of matlab chapter 2Solution of matlab chapter 2
Solution of matlab chapter 2AhsanIrshad8
 
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.Paolo Dagaojes
 

Mais procurados (15)

C2 st lecture 4 handout
C2 st lecture 4 handoutC2 st lecture 4 handout
C2 st lecture 4 handout
 
A study on number theory and its applications
A study on number theory and its applicationsA study on number theory and its applications
A study on number theory and its applications
 
C2 st lecture 3 handout
C2 st lecture 3 handoutC2 st lecture 3 handout
C2 st lecture 3 handout
 
9.4 Cramer's Rule
9.4 Cramer's Rule9.4 Cramer's Rule
9.4 Cramer's Rule
 
Dividing polynomials
Dividing polynomialsDividing polynomials
Dividing polynomials
 
C2 st lecture 8 pythagoras and trigonometry handout
C2 st lecture 8   pythagoras and trigonometry handoutC2 st lecture 8   pythagoras and trigonometry handout
C2 st lecture 8 pythagoras and trigonometry handout
 
10th arithmetic progression solves questions
10th arithmetic progression solves questions10th arithmetic progression solves questions
10th arithmetic progression solves questions
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
 
Binomial
BinomialBinomial
Binomial
 
GCSE Foundation Maths
GCSE Foundation MathsGCSE Foundation Maths
GCSE Foundation Maths
 
algebraic expression class VIII
algebraic expression class VIIIalgebraic expression class VIII
algebraic expression class VIII
 
The binomial expansion
The binomial expansionThe binomial expansion
The binomial expansion
 
Solution of matlab chapter 2
Solution of matlab chapter 2Solution of matlab chapter 2
Solution of matlab chapter 2
 
Vedic maths
Vedic mathsVedic maths
Vedic maths
 
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.
Grade 9: Mathematics Unit 1 Quadratic Equations and Inequalities.
 

Semelhante a Variables and Statements

Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsYashJain47002
 
Real number system full
Real  number  system fullReal  number  system full
Real number system fullAon Narinchoti
 
Real number system full
Real  number  system fullReal  number  system full
Real number system fullAon Narinchoti
 
Slides Vba Mamb
Slides Vba MambSlides Vba Mamb
Slides Vba Mambmaretec
 
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2Yo Halb
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programJyotiprakashMishra18
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxssuser01e301
 
Programming in python
Programming in pythonProgramming in python
Programming in pythonIvan Rojas
 
3.1 Functions
3.1 Functions3.1 Functions
3.1 Functionssmiller5
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012Shani729
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational AlgebraPyingkodi Maran
 

Semelhante a Variables and Statements (20)

Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
 
Real number system full
Real  number  system fullReal  number  system full
Real number system full
 
Real number system full
Real  number  system fullReal  number  system full
Real number system full
 
Slides Vba Mamb
Slides Vba MambSlides Vba Mamb
Slides Vba Mamb
 
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and program
 
Big o notation
Big o notationBig o notation
Big o notation
 
Big o notation
Big o notationBig o notation
Big o notation
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
 
Programming in python
Programming in pythonProgramming in python
Programming in python
 
3.1 Functions
3.1 Functions3.1 Functions
3.1 Functions
 
1. basic theories of information
1. basic theories of information1. basic theories of information
1. basic theories of information
 
Input output
Input outputInput output
Input output
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
 
Input output
Input outputInput output
Input output
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 

Mais de primeteacher32

Mais de primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Introduction to GUIs with guizero
Introduction to GUIs with guizeroIntroduction to GUIs with guizero
Introduction to GUIs with guizero
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Conditionals
ConditionalsConditionals
Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 
Hashes
HashesHashes
Hashes
 

Último

女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证obuhobo
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Datingkojalkojal131
 
Zeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effectZeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effectPriyanshuRawat56
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...amitlee9823
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...poojakaurpk09
 
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfExperience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfSoham Mondal
 
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big BoodyDubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boodykojalkojal131
 
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)Delhi Call girls
 
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkSujalTamhane
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceanilsa9823
 
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...amitlee9823
 
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home Made
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home MadeDubai Call Girls Naija O525547819 Call Girls In Dubai Home Made
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home Madekojalkojal131
 
Get To Know About "Lauren Prophet-Bryant''
Get To Know About "Lauren Prophet-Bryant''Get To Know About "Lauren Prophet-Bryant''
Get To Know About "Lauren Prophet-Bryant''Lauren Prophet-Bryant
 
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual serviceanilsa9823
 
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..Masuk Ahmed
 

Último (20)

女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
 
Sensual Moments: +91 9999965857 Independent Call Girls Paharganj Delhi {{ Mon...
Sensual Moments: +91 9999965857 Independent Call Girls Paharganj Delhi {{ Mon...Sensual Moments: +91 9999965857 Independent Call Girls Paharganj Delhi {{ Mon...
Sensual Moments: +91 9999965857 Independent Call Girls Paharganj Delhi {{ Mon...
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
 
Zeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effectZeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effect
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
 
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfExperience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
 
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big BoodyDubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
 
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
 
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Ex 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmk
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
 
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
 
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home Made
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home MadeDubai Call Girls Naija O525547819 Call Girls In Dubai Home Made
Dubai Call Girls Naija O525547819 Call Girls In Dubai Home Made
 
Get To Know About "Lauren Prophet-Bryant''
Get To Know About "Lauren Prophet-Bryant''Get To Know About "Lauren Prophet-Bryant''
Get To Know About "Lauren Prophet-Bryant''
 
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Nishatganj Lucknow best sexual service
 
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Patparganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..
 

Variables and Statements

  • 2. Variables • A variable is a name that represents a value stored in the computer’s memory. • So far, applications that you have created have stored data only in component properties. • Variables are objects that can save data temporarily to reuse & simplify code. • Variable names should be descriptive of what they are storing • Variables allow to update and modify code more efficiently
  • 3. Variable Types • Programming languages have a plethora of variable types, however… • Scripting languages like Python have tried to streamline these types to the bare bones essential categories. • There is a default variable type in scripting languages, string. • However Python is smart enough to know what information is stored in a variable and knows behaviors associated with it. That way if you store a number in a variable it will automatically convert it for you to that type. • Question: What are some other types of data that we could store?
  • 4. Declaring, Initializing & Assigning Variables • Declaring a Variable : N/A in python • Initializing a Variable : Creating a variable and setting a starting value to a variable. • Assigning/Reassigning a Variable : When we set a value to a variable
  • 5. Creating a Programming Statement • A programming statement is a complete action comprised of expressions. • A mathematical equation • Initializing a variable • Assigning a variable to an LED • Ex. red = LED(17) • name = “Jason” • age = 34 • lie = True • money = math.floor(1.92)
  • 6. Variable Output • Question: What is the difference between this and printing strings?
  • 7. Arithmetic Operators Name Meaning Example Result + Addition 34 + 1 35 - Subtraction 34.0 – 0.1 33.9 * Multiplication 300 * 30 9000 / Float Division 1 / 2 0.5 // Integer Division 1 // 2 0 ** Exponentiation 4 ** 0.5 2.0 % Remainder 20 % 3 2
  • 8. The Power of Remainders • Question: What is the minimum number of coins to make $.97, how did you come to this conclusion? Saturday is the 6th day in a week A week has 7 days After 10 days The 2nd day in a week is Tuesday (6 + 10) % 7 is 2 124 3 12 0 73 2 6 1 268 3 24 2 Remainder Quotient 2013 1 13 7 DividendDivisor
  • 9. Arithmetic Expressions and Statements is translated to (3+4*x)/5 – 10*(y-5)*(a+b+c)/x + 9*(4/x + (9+x)/y) ) 94 (9 ))(5(10 5 43 y x xx cbayx     
  • 10. Built in Math Functions >>> max(2, 3, 4) # Returns a maximum number 4 >>> min(2, 3, 4) # Returns a minimum number 2 >>> round(3.51) # Rounds to its nearest integer 4 >>> round(3.4) # Rounds to its nearest integer 3 >>> abs(-3) # Returns the absolute value 3 >>> pow(2, 3) # Same as 2 ** 3 8
  • 11. The Math Module Function Description Example fabs(x) Returns the absolute value of the argument. fabs(-2) is 2 ceil(x) Rounds x up to its nearest integer and ceil(2.1) is 3 returns this integer. ceil(-2.1) is -2 floor(x) Rounds x down to its nearest integer and floor(2.1) is 2 returns this integer. floor(-2.1) is -3 exp(x) Returns the exponential function of x (e^x). exp(1) is 2.71828 log(x) Returns the natural logarithm of x. log(2.71828) is 1.0 log(x, base) Returns the logarithm of x for the specified log10(10, 10) is 1 base. sqrt(x) Returns the square root of x. sqrt(4.0) is 2 sin(x) Returns the sine of x. x represents an angle sin(3.14159 / 2) is 1 in radians. sin(3.14159) is 0 asin(x) Returns the angle in radians for the inverse asin(1.0) is 1.57 of sine. asin(0.5) is 0.523599 cos(x) Returns the cosine of x. x represents an cos(3.14159 / 2) is 0 angle in radians. cos(3.14159) is -1 acos(x) Returns the angle in radians for the inverse acos(1.0) is 0 of cosine. acos(0.5) is 1.0472 tan(x) Returns the tangent of x. x represents an tan(3.14159 / 4) is 1 angle in radians. tan(0.0) is 0 fmod(x, y) Returns the remainder of x/y as double. fmod(2.4, 1.3) is 1.1 degrees(x) Converts angle x from radians to degrees degrees(1.57) is 90 radians(x) Converts angle x from degrees to radians radians(90) is 1.57
  • 12. Checkpoint • 1. What is a variable? • 2. Why do we have naming conventions? • 3. What is the difference between a programming expression and a statement?

Notas do Editor

  1. Introduce other types like float, int, long, string, char and Boolean but with discuss further conversions later