SlideShare a Scribd company logo
1 of 9
The print() function allows a program to display text onto the
console.
The print function will print everything as strings and anything
that is not already a string is automatically converted to its string
representation.
>>> print("Hello World!!")
Hello World!!
They are
1. str.format()
2. f-strings
Use str.format() method if you need to insert the value
of a variable, expression or an object into another string
and display it to the user as a single string.
syntax for format() method is, str.format(p0, p1, ...,
k0=v0, k1=v1, ...)
where p0, p1,... are called as positional arguments and,
k0, k1,... are keyword arguments with their assigned
values of v0, v1,... respectively.
Positional arguments are a list of arguments that can be
accessed with an index of argument inside curly braces
like {index}. Index value starts from zero.
Keyword arguments are a list of arguments of type
keyword = value, that can be accessed with the name of
the argument inside curly braces like {keyword}.
The indexed or keyword curly braces are replaced by
their corresponding argument values and is displayed
as a single string to the user.
Program 2.1: Program to Demonstrate input() and print()
Functions
1. country = input("Which country do you live in?")
2. print("I live in {0}".format(country))
Output
Which country do you live in? India
I live in India
 Program to Demonstrate the Positional Change of Indexes of
Arguments
1. a = 10
2. b = 20
3. print("The values of a is {0} and b is {1}".format(a, b))
4. print("The values of b is {1} and a is {0}".format(a, b))
 Output
The values of a is 10 and b is 20
The values of b is 20 and a is 10
This allows for re-arranging the order of display without
changing the arguments
1. >>> print("Give me {ball} ball".format(ball = "tennis"))
Give me tennis ball
The keyword argument {ball} gets replaced with its assigned
value
 Given the Radius, Write Python Program to Find the Area and
Circumference of a Circle
1. radius = int(input("Enter the radius of a circle"))
2. area_of_a_circle = 3.1415 * radius * radius
3. circumference_of_a_circle = 2 * 3.1415 * radius
4. print(f"Area = {area_of_a_circle} and Circumference =
{circumference_of_a_circle}")
 Output
Enter the radius of a circle 5
Area = 78.53750000000001 and Circumference = 31.415000000000003
Write Python Program to Convert the Given Number of Days to a
Measure of Time Given in Years, Weeks and Days. For Example, 375
Days Is Equal to 1 Year, 1 Week and 3 Days (Ignore Leap Year).
1. number_of_days = int(input("Enter number of days"))
2. number_of_years = int(number_of_days/365)
3. number_of_weeks = int(number_of_days % 365 / 7)
4. remaining_number_of_days = int(number_of_days % 365 % 7)
5. print(f"Years = {number_of_years}, Weeks = {number_of_weeks},
Days = {remaining_number_of_days}")
 Output
Enter number of days375
Years = 1, Weeks = 1, Days = 3

More Related Content

Similar to Function for python for the embedded system

1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
hara69
 
C++ Pointers with Examples.docx
C++ Pointers with Examples.docxC++ Pointers with Examples.docx
C++ Pointers with Examples.docx
JoeyDelaCruz22
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
info114
 

Similar to Function for python for the embedded system (20)

Pointers+(2)
Pointers+(2)Pointers+(2)
Pointers+(2)
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
 
Engineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptxEngineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptx
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry PiRaspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry Pi
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
functions.docx
functions.docxfunctions.docx
functions.docx
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
 
Pointers
PointersPointers
Pointers
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
C++ Pointers with Examples.docx
C++ Pointers with Examples.docxC++ Pointers with Examples.docx
C++ Pointers with Examples.docx
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 
functions- best.pdf
functions- best.pdffunctions- best.pdf
functions- best.pdf
 
Pointers.pdf
Pointers.pdfPointers.pdf
Pointers.pdf
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
Arrays
ArraysArrays
Arrays
 

Recently uploaded

Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
drjose256
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
MaherOthman7
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 

Recently uploaded (20)

litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 

Function for python for the embedded system

  • 1.
  • 2. The print() function allows a program to display text onto the console. The print function will print everything as strings and anything that is not already a string is automatically converted to its string representation. >>> print("Hello World!!") Hello World!! They are 1. str.format() 2. f-strings
  • 3. Use str.format() method if you need to insert the value of a variable, expression or an object into another string and display it to the user as a single string. syntax for format() method is, str.format(p0, p1, ..., k0=v0, k1=v1, ...) where p0, p1,... are called as positional arguments and, k0, k1,... are keyword arguments with their assigned values of v0, v1,... respectively.
  • 4. Positional arguments are a list of arguments that can be accessed with an index of argument inside curly braces like {index}. Index value starts from zero. Keyword arguments are a list of arguments of type keyword = value, that can be accessed with the name of the argument inside curly braces like {keyword}. The indexed or keyword curly braces are replaced by their corresponding argument values and is displayed as a single string to the user.
  • 5. Program 2.1: Program to Demonstrate input() and print() Functions 1. country = input("Which country do you live in?") 2. print("I live in {0}".format(country)) Output Which country do you live in? India I live in India
  • 6.  Program to Demonstrate the Positional Change of Indexes of Arguments 1. a = 10 2. b = 20 3. print("The values of a is {0} and b is {1}".format(a, b)) 4. print("The values of b is {1} and a is {0}".format(a, b))  Output The values of a is 10 and b is 20 The values of b is 20 and a is 10
  • 7. This allows for re-arranging the order of display without changing the arguments 1. >>> print("Give me {ball} ball".format(ball = "tennis")) Give me tennis ball The keyword argument {ball} gets replaced with its assigned value
  • 8.  Given the Radius, Write Python Program to Find the Area and Circumference of a Circle 1. radius = int(input("Enter the radius of a circle")) 2. area_of_a_circle = 3.1415 * radius * radius 3. circumference_of_a_circle = 2 * 3.1415 * radius 4. print(f"Area = {area_of_a_circle} and Circumference = {circumference_of_a_circle}")  Output Enter the radius of a circle 5 Area = 78.53750000000001 and Circumference = 31.415000000000003
  • 9. Write Python Program to Convert the Given Number of Days to a Measure of Time Given in Years, Weeks and Days. For Example, 375 Days Is Equal to 1 Year, 1 Week and 3 Days (Ignore Leap Year). 1. number_of_days = int(input("Enter number of days")) 2. number_of_years = int(number_of_days/365) 3. number_of_weeks = int(number_of_days % 365 / 7) 4. remaining_number_of_days = int(number_of_days % 365 % 7) 5. print(f"Years = {number_of_years}, Weeks = {number_of_weeks}, Days = {remaining_number_of_days}")  Output Enter number of days375 Years = 1, Weeks = 1, Days = 3