SlideShare a Scribd company logo
1 of 8
Download to read offline
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
Python Programming
Tutorial 2
Learn & Lead
Eng. Ruwan Dissanayake
B.Sc.Eng(Hons) Electrical & Electronic Engineer , AMIESL
Former Engineer Corporate Strategy Sri lanka Telecom PLC
Dip.in. Counselling Psychology, Dip.in. Stress Management
Dip.in Buddhist Counselling Psychology(SIBA),
Dip.in Interior Designing, Design in Electrical Installation(IESL)
Certified Motivation Personality & Leadership Trainer
Certified Energy Healing Therapist & Counselor
077 593 10 68 / 071 241 70 27
PRE -ENGINEERING COURSE 2021
Tutorial 2-Individual
Python programming- Flow Control-if ....else
1. Develop a program which accepts a number (an amount of money to be paid by a
customer in rupees) entered from the keyboard. If the amount is greater than or equal to
1,000 rupees, a 5% discount is given to the customer.Then display the final amount that
thecustomerhastopay.
2. Modify the program for the question 1 so that it displays the message “No discount…”
iftheamountislessthan1,000.
3. Write a program that reads the marks obtained for a given subject and display the given
message.
• 0-50=>“Fail”
• 51-100=>“Pass”
4. Write a python program to implement the Number Guessing Game. In this game the
computer chooses a number between 1 and 10, and the player tries to guess the number
in one attempt. Each time the player enters a guess, the computer tells him whether the
guess istoohighortoolow.
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
5. writedown suitablecodingto find largestoftwogivennumbers
Guess My Number Game
Enter a guess between 1 and 10 : 2
Too low!
Guess no=4 Guess no=4
6. Write a Python program which accepts the radius of a circle from the user and compute
thearea.
Guess My Number Game
Enter a guess between 1 and 10 : 7
Too high!
Input: num1 = 10, num1 = 45
Output: Largest number = 45
Input: num1 = 20, num1 = 18
Output: Largest number = 20
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
7. WriteaPythonprogramtogetthevolumeofasphere
8. Write a Python program to get the absolute difference between a given number and 17,
ifthenumberisgreaterthan17returndoubletheabsolutedifference.
9. Write a Python program to calculate the sum of three given numbers, if the values are
equalthenreturnthreetimesoftheirsum.
11. Write a Python program to find whether a given number (accept from the user) is even
orodd,printoutanappropriatemessagetotheuser.
Input: num = 10
Output: This is an even number
Input: num = 1211
Output: This is an odd number
12.Write a Python program that
will accept the base and
height of a triangle and
computethearea.
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
13. Write a Python program to compute the future value(maturity Value) of a specified
principalamount,rateofinterest,andanumberofyears.
Input: Princi_Amount = 10000, interest = 3.5, years = 7
Output: Maturity Value : 12722.79
14. Write a Python program which will return true if the two given integer values are equal
ortheirsumordifferenceis5
Input: num1 = 7
num2 = 3
Output: false
Input: num1 = 7
num2 = 2
Output: true
15. Write a Python program to compute the distance between the points (x1, y1) and
(x2,y2).
16.WriteaPythonprogramtoconvertallunitsoftimeintoseconds.
Input:
Output:
days: 4
hours: 5
minutes: 20
seconds: 10
The amounts of seconds 364810
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
17.WriteaPythonprogramtocalculatemidpointsofaline
Input:
Output:
Calculate the midpoint of a line :
The value of x (the first endpoint) 2
The value of y (the first endpoint) 2
The value of x (the first endpoint) 4
The value of y (the first endpoint) 4
The midpoint of line is :
The midpoint's x value is: 3.0
The midpoint's y value is: 3.0
18.WriteaPythonprogramtocalculatebodymassindex.
Input your height in meters: 1.2
Input your weight in Kilogram: 65
Your body mass index is: xxx
Output:
Input:
19.WriteaPythonprogramtoswap twovariables.
a : 20
b: 65
a=65 , b=20
Output:
Input:
20.WriteaPythonprogram toconverttemperaturefromFahrenheittoCelsius.
Temp.in Fahrenheit : 50
Temp.in Celsius : 10
Output:
Input:
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
21.WriteaPythonprogramtoconvertdegreetoradian.
Input:
Output:
Degree : 15
radians: 0.2619047619047619
22.WriteaPythonprogramtoconvertradiantodegree..
Input:
Output:
Radian : 52
Degree: 29.781818181818185
23.WriteaPythonprogramtocalculate volumeandsurfaceareaofacylinder
Input:
Output:
Height : 4
Radius : 6
Volume is : 452.57142857142856
Surface Area is : 377.1428571428571
24.WriteaPythonprogramtofind therootsofaquadraticfunction.
Input:
Output:
Quadratic function : (a * x^2) + b*x + c
a: 5
b: 20
c: 10
There are 2 roots: -0.585786 and -3.414214
Input:
Input:
Output:
Output:
Quadratic function : (a * x^2) + b*x + c
a: 1
b: 4
c: 2
There is one root: 2
Quadratic function : (a * x^2) + b*x + c
a: 1
b: 2
c: 4
No roots
MIET MiET SCHOOL
of Engineering
Engineers are driving the future
25.WriteaPythonprogramtocheckthevalidityofa simplePassword
Input:
Output:
Enter password : hello123
incorrect password
password = hello456
Input:
Output:
Enter password : hello456
You are welcome
password = hello456
26.modifythe25thprogram thatasks theusertoinputausernameandpassword.
Input:
Output:
username : Eng
password : hello456
incorrect password
password = hello456 password = hello456
user_name = Pre_Engineering user_name = Pre_Engineering
Input:
Output:
username : Pre_Engineering
password : hello456
You are welcome
Special notes
Ÿ Send your code & screenshots of the output as a single pdf file and do not forget to save your
documentusing your registrationnumber.
Ÿ (your Reg.Nois 96 => )
96. ME_96_YourName
Ÿ Please submit your assignment to mietschoolofengineering@gmail.com
MIET MiET SCHOOL
of Engineering
Engineers are driving the future

More Related Content

Recently uploaded

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 

Recently uploaded (20)

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

2.tutorial 2-if & else-

  • 1. MIET MiET SCHOOL of Engineering Engineers are driving the future Python Programming Tutorial 2 Learn & Lead Eng. Ruwan Dissanayake B.Sc.Eng(Hons) Electrical & Electronic Engineer , AMIESL Former Engineer Corporate Strategy Sri lanka Telecom PLC Dip.in. Counselling Psychology, Dip.in. Stress Management Dip.in Buddhist Counselling Psychology(SIBA), Dip.in Interior Designing, Design in Electrical Installation(IESL) Certified Motivation Personality & Leadership Trainer Certified Energy Healing Therapist & Counselor 077 593 10 68 / 071 241 70 27 PRE -ENGINEERING COURSE 2021
  • 2. Tutorial 2-Individual Python programming- Flow Control-if ....else 1. Develop a program which accepts a number (an amount of money to be paid by a customer in rupees) entered from the keyboard. If the amount is greater than or equal to 1,000 rupees, a 5% discount is given to the customer.Then display the final amount that thecustomerhastopay. 2. Modify the program for the question 1 so that it displays the message “No discount…” iftheamountislessthan1,000. 3. Write a program that reads the marks obtained for a given subject and display the given message. • 0-50=>“Fail” • 51-100=>“Pass” 4. Write a python program to implement the Number Guessing Game. In this game the computer chooses a number between 1 and 10, and the player tries to guess the number in one attempt. Each time the player enters a guess, the computer tells him whether the guess istoohighortoolow. MIET MiET SCHOOL of Engineering Engineers are driving the future 5. writedown suitablecodingto find largestoftwogivennumbers Guess My Number Game Enter a guess between 1 and 10 : 2 Too low! Guess no=4 Guess no=4 6. Write a Python program which accepts the radius of a circle from the user and compute thearea. Guess My Number Game Enter a guess between 1 and 10 : 7 Too high! Input: num1 = 10, num1 = 45 Output: Largest number = 45 Input: num1 = 20, num1 = 18 Output: Largest number = 20
  • 3. MIET MiET SCHOOL of Engineering Engineers are driving the future 7. WriteaPythonprogramtogetthevolumeofasphere 8. Write a Python program to get the absolute difference between a given number and 17, ifthenumberisgreaterthan17returndoubletheabsolutedifference. 9. Write a Python program to calculate the sum of three given numbers, if the values are equalthenreturnthreetimesoftheirsum. 11. Write a Python program to find whether a given number (accept from the user) is even orodd,printoutanappropriatemessagetotheuser. Input: num = 10 Output: This is an even number Input: num = 1211 Output: This is an odd number 12.Write a Python program that will accept the base and height of a triangle and computethearea.
  • 4. MIET MiET SCHOOL of Engineering Engineers are driving the future 13. Write a Python program to compute the future value(maturity Value) of a specified principalamount,rateofinterest,andanumberofyears. Input: Princi_Amount = 10000, interest = 3.5, years = 7 Output: Maturity Value : 12722.79 14. Write a Python program which will return true if the two given integer values are equal ortheirsumordifferenceis5 Input: num1 = 7 num2 = 3 Output: false Input: num1 = 7 num2 = 2 Output: true 15. Write a Python program to compute the distance between the points (x1, y1) and (x2,y2). 16.WriteaPythonprogramtoconvertallunitsoftimeintoseconds. Input: Output: days: 4 hours: 5 minutes: 20 seconds: 10 The amounts of seconds 364810
  • 5. MIET MiET SCHOOL of Engineering Engineers are driving the future 17.WriteaPythonprogramtocalculatemidpointsofaline Input: Output: Calculate the midpoint of a line : The value of x (the first endpoint) 2 The value of y (the first endpoint) 2 The value of x (the first endpoint) 4 The value of y (the first endpoint) 4 The midpoint of line is : The midpoint's x value is: 3.0 The midpoint's y value is: 3.0 18.WriteaPythonprogramtocalculatebodymassindex. Input your height in meters: 1.2 Input your weight in Kilogram: 65 Your body mass index is: xxx Output: Input: 19.WriteaPythonprogramtoswap twovariables. a : 20 b: 65 a=65 , b=20 Output: Input: 20.WriteaPythonprogram toconverttemperaturefromFahrenheittoCelsius. Temp.in Fahrenheit : 50 Temp.in Celsius : 10 Output: Input:
  • 6. MIET MiET SCHOOL of Engineering Engineers are driving the future 21.WriteaPythonprogramtoconvertdegreetoradian. Input: Output: Degree : 15 radians: 0.2619047619047619 22.WriteaPythonprogramtoconvertradiantodegree.. Input: Output: Radian : 52 Degree: 29.781818181818185 23.WriteaPythonprogramtocalculate volumeandsurfaceareaofacylinder Input: Output: Height : 4 Radius : 6 Volume is : 452.57142857142856 Surface Area is : 377.1428571428571 24.WriteaPythonprogramtofind therootsofaquadraticfunction. Input: Output: Quadratic function : (a * x^2) + b*x + c a: 5 b: 20 c: 10 There are 2 roots: -0.585786 and -3.414214 Input: Input: Output: Output: Quadratic function : (a * x^2) + b*x + c a: 1 b: 4 c: 2 There is one root: 2 Quadratic function : (a * x^2) + b*x + c a: 1 b: 2 c: 4 No roots
  • 7. MIET MiET SCHOOL of Engineering Engineers are driving the future 25.WriteaPythonprogramtocheckthevalidityofa simplePassword Input: Output: Enter password : hello123 incorrect password password = hello456 Input: Output: Enter password : hello456 You are welcome password = hello456 26.modifythe25thprogram thatasks theusertoinputausernameandpassword. Input: Output: username : Eng password : hello456 incorrect password password = hello456 password = hello456 user_name = Pre_Engineering user_name = Pre_Engineering Input: Output: username : Pre_Engineering password : hello456 You are welcome Special notes Ÿ Send your code & screenshots of the output as a single pdf file and do not forget to save your documentusing your registrationnumber. Ÿ (your Reg.Nois 96 => ) 96. ME_96_YourName Ÿ Please submit your assignment to mietschoolofengineering@gmail.com
  • 8. MIET MiET SCHOOL of Engineering Engineers are driving the future