SlideShare a Scribd company logo
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?

More Related Content

What's hot

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 applications
Itishree 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 Rule
smiller5
 
Dividing polynomials
Dividing polynomialsDividing polynomials
Dividing polynomials
Educació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 questions
Akshay Fegade
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
Nv Thejaswini
 
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 expansion
JJkedst
 
Solution of matlab chapter 2
Solution of matlab chapter 2Solution of matlab chapter 2
Solution of matlab chapter 2
AhsanIrshad8
 
Vedic maths
Vedic mathsVedic maths
Vedic maths
Parul Vadiya
 
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
 

What's hot (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.
 

Similar to 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 questions
YashJain47002
 
Real number system full
Real  number  system fullReal  number  system full
Real number system full
Aon Narinchoti
 
Real number system full
Real  number  system fullReal  number  system full
Real number system full
Aon Narinchoti
 
Slides Vba Mamb
Slides Vba MambSlides Vba Mamb
Slides Vba Mamb
maretec
 
[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 program
JyotiprakashMishra18
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
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
ssuser01e301
 
Programming in python
Programming in pythonProgramming in python
Programming in python
Ivan Rojas
 
3.1 Functions
3.1 Functions3.1 Functions
3.1 Functions
smiller5
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
chestialtaff
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
Shani729
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
Pyingkodi Maran
 
Input output
Input outputInput output
Input output
nicky_walters
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Khulna University
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
TANVIRAHMED611926
 

Similar to 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
 

More from primeteacher32

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

More from 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
 

Recently uploaded

DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
FarzanaRbcomcs
 
New Explore Careers and College Majors 2024.pdf
New Explore Careers and College Majors 2024.pdfNew Explore Careers and College Majors 2024.pdf
New Explore Careers and College Majors 2024.pdf
Dr. Mary Askew
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
Ben Woelk, CISSP, CPTC
 
Brand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio IBrand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio I
thomasaolson2000
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
yuhofha
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
HeidiLivengood
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
atwvhyhm
 
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
larisashrestha558
 
Digital Marketing Training In Bangalore
Digital  Marketing Training In BangaloreDigital  Marketing Training In Bangalore
Digital Marketing Training In Bangalore
nidm599
 
Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!
LukeRoyak
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
23211a7274
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
mmorales2173
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
ssuser3e63fc
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
vencislavkaaa
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
yuhofha
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
Pushpendra Kumar
 
Midterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptxMidterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptx
Sheldon Byron
 
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Chapters 3  Contracts.pptx Chapters 3  Contracts.pptxChapters 3  Contracts.pptx Chapters 3  Contracts.pptx
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Sheldon Byron
 
Personal Brand exploration KE.pdf for assignment
Personal Brand exploration KE.pdf for assignmentPersonal Brand exploration KE.pdf for assignment
Personal Brand exploration KE.pdf for assignment
ragingokie
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
Manu Mitra
 

Recently uploaded (20)

DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
 
New Explore Careers and College Majors 2024.pdf
New Explore Careers and College Majors 2024.pdfNew Explore Careers and College Majors 2024.pdf
New Explore Careers and College Majors 2024.pdf
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
 
Brand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio IBrand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio I
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
 
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
 
Digital Marketing Training In Bangalore
Digital  Marketing Training In BangaloreDigital  Marketing Training In Bangalore
Digital Marketing Training In Bangalore
 
Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
 
Midterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptxMidterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptx
 
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Chapters 3  Contracts.pptx Chapters 3  Contracts.pptxChapters 3  Contracts.pptx Chapters 3  Contracts.pptx
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
 
Personal Brand exploration KE.pdf for assignment
Personal Brand exploration KE.pdf for assignmentPersonal Brand exploration KE.pdf for assignment
Personal Brand exploration KE.pdf for assignment
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
 

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?

Editor's Notes

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