SlideShare a Scribd company logo
1 of 18
Variables and
Expressions
CMSC 201
Chang (rev. 2015-02-05)
Today we start Python!
Two ways to use python:
 You can write a program, as a series of instructions
in a file, and then execute it.
 You can also test simple python commands in the
python interpreter.
Variables
Variables are names of places that store information.
Making variables in Python:
someVariable = 10
someVariable is a variable.
someVariable has value 10.
someVariable can have a different value later.
The = is called the assignment operator.
It allows you to change the value of a variable.
Variables
The right hand side of the assignment can be any
mathematical expression.
someVariable = 10
anotherVariable = 5 + 9
aThirdVariable = 10 * anotherVariable
someVariable = someVariable + anotherVariable
Whenever a variable is on the right hand side of an
expression, imagine it being replaced by whatever value is
currently stored in that variable.
Types
There are many different types of values !
 Numbers (integer or floating point)
 True / False values (called booleans)
 Strings (collections of characters)
aString = ‘Hello everyone’
x = 1.12
bool = True
Rules for Naming Variables
 Variable names are case sensitive.
Hello different from hello
 Only may contain alphabetic letters, underscores or
numbers.
 Should not start with a number.
 Cannot be any other python keyword (if, while, def, etc).
Give your variables meaningful names!
Output
We’d like to see what’s stored in our variables!
Python can print things for us:
print("Hello world")
You can also output the contents of variables:
someVariable = 10
print(someVariable)
You can even do combinations!
print("Your variable is ", someVariable)
Exercise
What will the following code snippet print?
a = 10
b = a * 5
c = "Your result is: "
print(c, b)
Exercise
What will the following code snippet print?
a = 10
b = a
a = 3
print(b)
There are two possible options for what this could do!
Any guesses?
Exercise
a = 10
b = a
a = 3
print(b)
It will print out 10. When you set one variable equal to
another, they don’t become linked; b is set to 10 and no
longer has anything else to do with a.
Input
Sometimes, we’d like the user to participate! We can also get
input from the user.
userInput = input("Please enter a number ")
print(userInput)
The output will look like this:
Please enter a number 10
10
Input
This line:
userInput = input("Please enter a number")
Takes whatever the user entered and stores it in the variable
named "userInput"
You can do this as many times as you like!
userInput1 = input("Enter first number.")
userInput2 = input("Enter second number.")
Input
Note: All input vlaues are strings.
a = "10"
b = 10
Variables a and b are different.
To turn an input into a number:
stringInput = input("Enter a number: ")
aNumber = int(stringInput)
int stands for integer
Operator Precedence
Like algebra, multiply and divide before adding and
subtracting:
3 * 4 + 5
is 17, not 27.
Python has many more operators. Precedence allows this
expression to make sense without parentheses:
3 * 4 + 5 > 2 + 2 * 4 and 17 + 9 > 31 - 22
Associativity
Associativity does not hold
(4.05 - 4.05) + 0.0000000000000001
does not equal
4.05 – (4.05 + 0.0000000000000001)
are not the same.
Most operations associate left to right by
default: a + b + c means (a + b) + c
More operators
Exponentiation:
2**3 is 8
2.5**2 is 6.25
Integer division (rounds down):
5//2 is 2
Modulus (gives the remainder):
28 % 5 is 3
Exercise
Write, on paper or on your computer, a program that asks
the user for two numbers a prints out the average.
Exercise
Pretend you’re writing a program to compute someone’s
weighted grade. You have so far:
hwWeight = 0.4
examWeight = 0.5
discussionWeight = 0.1
Write a program starting with these three lines that asks
the user for their homework grade, exam grades, and
discussion grades and prints out their total grade in the
class.

More Related Content

Similar to 03 Variables - Chang.pptx

Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)ExcellenceAcadmy
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.pptjaba kumar
 
Python programing
Python programingPython programing
Python programinghamzagame
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa Thapa
 
introduction to python in english presentation file
introduction to python in english presentation fileintroduction to python in english presentation file
introduction to python in english presentation fileRujanTimsina1
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsDhivyaSubramaniyam
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.pptbalewayalew
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
C++ Tutorial.docx
C++ Tutorial.docxC++ Tutorial.docx
C++ Tutorial.docxPinkiVats1
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressionsmaznabili
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for KidsAimee Maree Forsstrom
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdfMaheshGour5
 

Similar to 03 Variables - Chang.pptx (20)

Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Python programing
Python programingPython programing
Python programing
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 
introduction to python in english presentation file
introduction to python in english presentation fileintroduction to python in english presentation file
introduction to python in english presentation file
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
 
MODULE. .pptx
MODULE.                              .pptxMODULE.                              .pptx
MODULE. .pptx
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C++ Tutorial.docx
C++ Tutorial.docxC++ Tutorial.docx
C++ Tutorial.docx
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
M C6java2
M C6java2M C6java2
M C6java2
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
 
Python programming
Python  programmingPython  programming
Python programming
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdf
 
python
pythonpython
python
 

Recently uploaded

Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Data Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationData Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationBoston Institute of Analytics
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/managementakshesh doshi
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 

Recently uploaded (20)

Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Data Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationData Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health Classification
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/management
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 

03 Variables - Chang.pptx

  • 2. Today we start Python! Two ways to use python:  You can write a program, as a series of instructions in a file, and then execute it.  You can also test simple python commands in the python interpreter.
  • 3. Variables Variables are names of places that store information. Making variables in Python: someVariable = 10 someVariable is a variable. someVariable has value 10. someVariable can have a different value later. The = is called the assignment operator. It allows you to change the value of a variable.
  • 4. Variables The right hand side of the assignment can be any mathematical expression. someVariable = 10 anotherVariable = 5 + 9 aThirdVariable = 10 * anotherVariable someVariable = someVariable + anotherVariable Whenever a variable is on the right hand side of an expression, imagine it being replaced by whatever value is currently stored in that variable.
  • 5. Types There are many different types of values !  Numbers (integer or floating point)  True / False values (called booleans)  Strings (collections of characters) aString = ‘Hello everyone’ x = 1.12 bool = True
  • 6. Rules for Naming Variables  Variable names are case sensitive. Hello different from hello  Only may contain alphabetic letters, underscores or numbers.  Should not start with a number.  Cannot be any other python keyword (if, while, def, etc). Give your variables meaningful names!
  • 7. Output We’d like to see what’s stored in our variables! Python can print things for us: print("Hello world") You can also output the contents of variables: someVariable = 10 print(someVariable) You can even do combinations! print("Your variable is ", someVariable)
  • 8. Exercise What will the following code snippet print? a = 10 b = a * 5 c = "Your result is: " print(c, b)
  • 9. Exercise What will the following code snippet print? a = 10 b = a a = 3 print(b) There are two possible options for what this could do! Any guesses?
  • 10. Exercise a = 10 b = a a = 3 print(b) It will print out 10. When you set one variable equal to another, they don’t become linked; b is set to 10 and no longer has anything else to do with a.
  • 11. Input Sometimes, we’d like the user to participate! We can also get input from the user. userInput = input("Please enter a number ") print(userInput) The output will look like this: Please enter a number 10 10
  • 12. Input This line: userInput = input("Please enter a number") Takes whatever the user entered and stores it in the variable named "userInput" You can do this as many times as you like! userInput1 = input("Enter first number.") userInput2 = input("Enter second number.")
  • 13. Input Note: All input vlaues are strings. a = "10" b = 10 Variables a and b are different. To turn an input into a number: stringInput = input("Enter a number: ") aNumber = int(stringInput) int stands for integer
  • 14. Operator Precedence Like algebra, multiply and divide before adding and subtracting: 3 * 4 + 5 is 17, not 27. Python has many more operators. Precedence allows this expression to make sense without parentheses: 3 * 4 + 5 > 2 + 2 * 4 and 17 + 9 > 31 - 22
  • 15. Associativity Associativity does not hold (4.05 - 4.05) + 0.0000000000000001 does not equal 4.05 – (4.05 + 0.0000000000000001) are not the same. Most operations associate left to right by default: a + b + c means (a + b) + c
  • 16. More operators Exponentiation: 2**3 is 8 2.5**2 is 6.25 Integer division (rounds down): 5//2 is 2 Modulus (gives the remainder): 28 % 5 is 3
  • 17. Exercise Write, on paper or on your computer, a program that asks the user for two numbers a prints out the average.
  • 18. Exercise Pretend you’re writing a program to compute someone’s weighted grade. You have so far: hwWeight = 0.4 examWeight = 0.5 discussionWeight = 0.1 Write a program starting with these three lines that asks the user for their homework grade, exam grades, and discussion grades and prints out their total grade in the class.