SlideShare a Scribd company logo
1 of 16
Standard Input & Output
Team Emertxe
Output Statements
Output Statements
Print()
•
•
print(), when called simply throws the cursor to the next line
Means, a blank line will be displayed
Output Statements
Print(“string”)
Example Output
print()
Prints the 'n' character
print("Hello") Hello
print('Hello') Hello
print("Hello nWorld") Hello
World
print("Hello tWorld") Hello World
print("Hello nWorld") Hello nWorld
print(3 * 'Hello') HelloHelloHello
print("Hello"+"World") HelloWorld
print("Hello","World") Hello World
Output Statements
Print(variable list)
Example Output
a, b = 1, 2
print(a, b)
1 2
print(a, b, sep=",") 1,2
print(a, b, sep=':') 1:2
print(a, b, sep='---') 1---2
print("Hello", end="")
print("World")
HelloWorld
print("Hello", end="t")
print("World")
Hello World
Output Statements
Print(object)
Example Output
lst = [10, 'A', "Hai"]
print(lst) [10, 'A', 'Hai']
d = {10: "Ram", 20: "Amar"}
print(d)
{10: 'Ram', 20: 'Amar'}
●
Objects like list, tuples or dictionaries can be displayed
Output Statements
Print(“string”, variable list)
Example Output
a = 2
print(a, ": Even Number") 2 : Even Number
You typed 2 as Input
print("You typed", a, "as Input")
Output Statements
Print(formatted string)
Syntax: print("formatted string" % (varaible list))
Example Output
a = 10
print("The value of a: %i" % a) The value of a: 10
a, b = 10, 20
print("a: %dtb: %d" % (a, b))
a: 10 b: 20
name = "Ram" Hai Ram
print("Hai %s" % name) Hai ( Ram)
print("Hai (%20s)" % name) Hai (Ram )
print("Hai (%-20s)" % name)
print("%c" % name[2]) m
print("%s" % name[0:2]) Ra
num = 123.345727
print("Num: %f" % num)
print("Num: %8.2f" % num)
Num: 123.345727
Num: 123.35
Output Statements
Print(formatted string)
Syntax: print("formatted string" % (varaible list))
Example Output
a, b, c = 1, 2, 3
print("First= {0}". format(a))
print("First= {0}, Second= {1}". format(a, b)) First= 1
print("First= {one}, Second= {two}". format(one=a, two=b)) First= 1, Second= 2
print("First= {}, Second= {}". format(a, b)) First= 1, Second= 2
First= 1, Second= 2
name, salary = "Ram", 123.45
print("Hello {0}, your salary: {1}". format(name, salary))
print("Hello {n}, your salary: {s}". format(n=name, s=salary))
print("Hello {:s}, your salary: {:.2f}". format(name, salary))
print("Hello %s, your salary: %.2f" % (name, salary))
Hello Ram, your salary: 123.45
Hello Ram, your salary: 123.45
Hello Ram, your salary: 123.45
Hello Ram, your salary: 123.45
Input Statements
Input Statements
Input()
Example
str = input()
print(str)
str = input("Enter the name: ")
print(str)
a = int(input("Enter the number: "))
print(a)
b = float(input("Enter the float number: "))
print(b)
Command Line Arguments
CLA
Example
1 #To display CLA
2
3 import sys
4
5 #Get the no. of CLA
6n = len(sys.argv)
7
8 #Get the arguments
9args = sys.argv
10
11 #Print the 'n'
12print("No. Of CLA: ", n)
13
14 #print the arguments in one shot
15print(args)
16
17 #Print the arguments one by one
18 for i in args:
19 print(i)
CLA
Parsing CLA
● argparse module is useful to develop user-friendly programs
This module automatically generates help and usage messages
May also display appropriate error messages
●
●
CLA
Parsing CLA: Steps
● Step-1: Import argparse module
import argparse
●
●
Step-2: Create an Object of ArgumentParser
parser = argparse.ArgumentParser(description="This program displays square of two numbers")
Step-2a: If programmer does not want to display description, then above step
can be skipped
parser = argparse.ArgumentParser()
● Step-3: Add the arguments to the parser
parser.add_argument("num", type=int, help="Enter only int number.")
args = parser.parse_args()
● Step-4: Retrieve the arguments
● Step-5: Access the arguments
args.num
THANK YOU

More Related Content

Similar to inputoutput.pptx

Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Paige Bailey
 
Practical File waale code.pdf
Practical File waale code.pdfPractical File waale code.pdf
Practical File waale code.pdfFriendsStationary
 
fds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdffds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdfGaneshPawar819187
 
Python real time tutorial
Python real time tutorialPython real time tutorial
Python real time tutorialRajeev Kumar
 
Session -5for students.pdf
Session -5for students.pdfSession -5for students.pdf
Session -5for students.pdfpriyanshusoni53
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189Mahmoud Samir Fayed
 
Preprocessor Programming
Preprocessor ProgrammingPreprocessor Programming
Preprocessor Programminglactrious
 
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212Mahmoud Samir Fayed
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...AntareepMajumder
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181Mahmoud Samir Fayed
 
Python basic
Python basic Python basic
Python basic sewoo lee
 
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210Mahmoud Samir Fayed
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
 

Similar to inputoutput.pptx (20)

Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
Practical File waale code.pdf
Practical File waale code.pdfPractical File waale code.pdf
Practical File waale code.pdf
 
fds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdffds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdf
 
String_C.pptx
String_C.pptxString_C.pptx
String_C.pptx
 
Foxpro (1)
Foxpro (1)Foxpro (1)
Foxpro (1)
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Python real time tutorial
Python real time tutorialPython real time tutorial
Python real time tutorial
 
Session -5for students.pdf
Session -5for students.pdfSession -5for students.pdf
Session -5for students.pdf
 
Python crush course
Python crush coursePython crush course
Python crush course
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189
 
Preprocessor Programming
Preprocessor ProgrammingPreprocessor Programming
Preprocessor Programming
 
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Struct examples
Struct examplesStruct examples
Struct examples
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181
 
Python basic
Python basic Python basic
Python basic
 
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 

More from Venkateswara Babu Ravipati (12)

EG-Unit-2- Points.pptx
EG-Unit-2- Points.pptxEG-Unit-2- Points.pptx
EG-Unit-2- Points.pptx
 
EG- Unit 1.pptx
EG- Unit 1.pptxEG- Unit 1.pptx
EG- Unit 1.pptx
 
Chapter5.pptx
Chapter5.pptxChapter5.pptx
Chapter5.pptx
 
PP ECE A Sec UNIT-1.pptx
PP ECE A Sec UNIT-1.pptxPP ECE A Sec UNIT-1.pptx
PP ECE A Sec UNIT-1.pptx
 
python unit 2.pptx
python unit 2.pptxpython unit 2.pptx
python unit 2.pptx
 
Data types.pdf
Data types.pdfData types.pdf
Data types.pdf
 
types.pdf
types.pdftypes.pdf
types.pdf
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 
cad cam and robotics.pptx
cad cam and robotics.pptxcad cam and robotics.pptx
cad cam and robotics.pptx
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
Le and ne algorithms
Le and ne algorithmsLe and ne algorithms
Le and ne algorithms
 

Recently uploaded

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

inputoutput.pptx

  • 1. Standard Input & Output Team Emertxe
  • 3. Output Statements Print() • • print(), when called simply throws the cursor to the next line Means, a blank line will be displayed
  • 4. Output Statements Print(“string”) Example Output print() Prints the 'n' character print("Hello") Hello print('Hello') Hello print("Hello nWorld") Hello World print("Hello tWorld") Hello World print("Hello nWorld") Hello nWorld print(3 * 'Hello') HelloHelloHello print("Hello"+"World") HelloWorld print("Hello","World") Hello World
  • 5. Output Statements Print(variable list) Example Output a, b = 1, 2 print(a, b) 1 2 print(a, b, sep=",") 1,2 print(a, b, sep=':') 1:2 print(a, b, sep='---') 1---2 print("Hello", end="") print("World") HelloWorld print("Hello", end="t") print("World") Hello World
  • 6. Output Statements Print(object) Example Output lst = [10, 'A', "Hai"] print(lst) [10, 'A', 'Hai'] d = {10: "Ram", 20: "Amar"} print(d) {10: 'Ram', 20: 'Amar'} ● Objects like list, tuples or dictionaries can be displayed
  • 7. Output Statements Print(“string”, variable list) Example Output a = 2 print(a, ": Even Number") 2 : Even Number You typed 2 as Input print("You typed", a, "as Input")
  • 8. Output Statements Print(formatted string) Syntax: print("formatted string" % (varaible list)) Example Output a = 10 print("The value of a: %i" % a) The value of a: 10 a, b = 10, 20 print("a: %dtb: %d" % (a, b)) a: 10 b: 20 name = "Ram" Hai Ram print("Hai %s" % name) Hai ( Ram) print("Hai (%20s)" % name) Hai (Ram ) print("Hai (%-20s)" % name) print("%c" % name[2]) m print("%s" % name[0:2]) Ra num = 123.345727 print("Num: %f" % num) print("Num: %8.2f" % num) Num: 123.345727 Num: 123.35
  • 9. Output Statements Print(formatted string) Syntax: print("formatted string" % (varaible list)) Example Output a, b, c = 1, 2, 3 print("First= {0}". format(a)) print("First= {0}, Second= {1}". format(a, b)) First= 1 print("First= {one}, Second= {two}". format(one=a, two=b)) First= 1, Second= 2 print("First= {}, Second= {}". format(a, b)) First= 1, Second= 2 First= 1, Second= 2 name, salary = "Ram", 123.45 print("Hello {0}, your salary: {1}". format(name, salary)) print("Hello {n}, your salary: {s}". format(n=name, s=salary)) print("Hello {:s}, your salary: {:.2f}". format(name, salary)) print("Hello %s, your salary: %.2f" % (name, salary)) Hello Ram, your salary: 123.45 Hello Ram, your salary: 123.45 Hello Ram, your salary: 123.45 Hello Ram, your salary: 123.45
  • 11. Input Statements Input() Example str = input() print(str) str = input("Enter the name: ") print(str) a = int(input("Enter the number: ")) print(a) b = float(input("Enter the float number: ")) print(b)
  • 13. CLA Example 1 #To display CLA 2 3 import sys 4 5 #Get the no. of CLA 6n = len(sys.argv) 7 8 #Get the arguments 9args = sys.argv 10 11 #Print the 'n' 12print("No. Of CLA: ", n) 13 14 #print the arguments in one shot 15print(args) 16 17 #Print the arguments one by one 18 for i in args: 19 print(i)
  • 14. CLA Parsing CLA ● argparse module is useful to develop user-friendly programs This module automatically generates help and usage messages May also display appropriate error messages ● ●
  • 15. CLA Parsing CLA: Steps ● Step-1: Import argparse module import argparse ● ● Step-2: Create an Object of ArgumentParser parser = argparse.ArgumentParser(description="This program displays square of two numbers") Step-2a: If programmer does not want to display description, then above step can be skipped parser = argparse.ArgumentParser() ● Step-3: Add the arguments to the parser parser.add_argument("num", type=int, help="Enter only int number.") args = parser.parse_args() ● Step-4: Retrieve the arguments ● Step-5: Access the arguments args.num