Python Interactive Shell

Python Interactive Shell అంటే ఏమిటి?

Python Interactive Shell అనేది Python code ను ఒక్కో line గా వెంటనే type చేసి run చేయడానికి ఉపయోగించే స్థలం. దీనిని Python REPL అని కూడా అంటారు. REPL అంటే Read, Evaluate, Print, Loop.

Interactive Shellలో మనం code type చేసిన వెంటనే Python దాని resultను చూపిస్తుంది. ఒక చిన్న calculation, expression లేదా Python commandను త్వరగా test చేయడానికి ఇది చాలా ఉపయోగకరం.

Interactive Shell ఎందుకు ఉపయోగిస్తాము?

  • చిన్న Python codeను వెంటనే పరీక్షించడానికి.
  • Calculations చేయడానికి.
  • Python syntaxను practice చేయడానికి.
  • ఏదైనా expression resultను త్వరగా తెలుసుకోవడానికి.
  • కొత్త function లేదా command ఎలా పనిచేస్తుందో పరిశీలించడానికి.

Interactive Shell ఎలా పనిచేస్తుంది?

Python Shell open చేసినప్పుడు >>> అనే prompt కనిపిస్తుంది. ఈ prompt తర్వాత Python code type చేసి Enter key నొక్కాలి. Python ఆ lineను వెంటనే execute చేసి resultను చూపిస్తుంది.

ఒక code line పూర్తికాకపోతే Python సాధారణంగా ... అనే continuation promptను చూపిస్తుంది. అయితే ఈ lessonలో మనం simple one-line commandsతో practice చేస్తాము.

Python Interactive Shell ఎలా open చేయాలి?

  1. Command Prompt లేదా Terminal open చేయండి.
  2. python లేదా కొన్ని systemsలో python3 type చేయండి.
  3. Enter key నొక్కండి.
  4. >>> prompt కనిపిస్తే Interactive Shell readyగా ఉన్నట్లు అర్థం.

VS Codeలో కూడా Terminalను open చేసి ఇదే విధంగా Python Shellను start చేయవచ్చు.

Shell నుంచి ఎలా బయటకు రావాలి?

Interactive Shell నుంచి బయటకు రావడానికి exit() type చేసి Enter నొక్కవచ్చు. Windowsలో Ctrl + Z, తరువాత Enter కూడా ఉపయోగించవచ్చు. macOS లేదా Linuxలో సాధారణంగా Ctrl + D ఉపయోగించవచ్చు.

Simple Explanation

Interactive Shellను ఒక చిన్న Python laboratoryలా ఊహించుకోండి. మనం ఒక command ఇస్తే Python వెంటనే దాని resultను చూపిస్తుంది.

ఉదాహరణకు, 2 + 3 type చేస్తే Python వెంటనే 5 చూపిస్తుంది. ఒక complete Python file తయారు చేయాల్సిన అవసరం లేదు. అందువల్ల చిన్న experiments మరియు quick practice కోసం Interactive Shell చాలా సులభమైనది.

Shellలో కనిపించే >>> Python codeలో భాగం కాదు. అది Python మీ command కోసం ఎదురుచూస్తోందని చూపించే prompt మాత్రమే. కాబట్టి code copy చేసేటప్పుడు >>>ను type చేయకండి.

Real-Life Example

ఒక calculator appలో numberలు type చేస్తే వెంటనే answer కనిపిస్తుంది. Python Interactive Shell కూడా అదే విధంగా పనిచేస్తుంది. మీరు ఒక calculation లేదా command ఇస్తే Python వెంటనే దాని resultను చూపిస్తుంది. చిన్న calculation కోసం పూర్తి program రాయాల్సిన అవసరం ఉండదు.

Code Examples

Interactive Shellలో calculation చేయడం

2 + 3

ఈ expressionను Interactive Shellలో type చేసి Enter నొక్కితే Python addition చేసి resultను వెంటనే చూపిస్తుంది.

5

Interactive Shellలో print() ఉపయోగించడం

print("Hello, Python!")

print() function ద్వారా textను screenపై చూపించవచ్చు. Interactive Shellలో line execute చేసిన వెంటనే text కనిపిస్తుంది.

Hello, Python!

Interactive Shellలో ఒక valueను ఉపయోగించడం

number = 10
number * 2

మొదటి lineలో number అనే nameకు 10 value ఇస్తాము. రెండవ lineలో ఆ valueను 2తో multiply చేస్తాము. Interactive Shellలో మొదటి line తర్వాత prompt తిరిగి వస్తుంది; తరువాతి lineను type చేయవచ్చు.

20

Line-by-Line Explanation

2 + 3
ఈ lineలో రెండు numbersను addition చేస్తున్నాము. Python ఈ expressionను evaluate చేసి resultగా 5ను వెంటనే చూపిస్తుంది.
print(“Hello, Python!”)
ఈ lineలో print() function ఉపయోగించబడింది. Quotesలో ఉన్న textను Python screenపై చూపిస్తుంది. Enter నొక్కిన వెంటనే Hello, Python! కనిపిస్తుంది.
number = 10
ఈ lineలో number అనే nameకు 10 valueను assign చేస్తున్నాము. Python ఈ valueను గుర్తుంచుకుంటుంది, కాబట్టి తరువాతి commandలో numberను ఉపయోగించవచ్చు.
number * 2
ఈ lineలో numberలో ఉన్న 10 valueను 2తో multiply చేస్తున్నాము. Python calculation చేసి resultగా 20ను చూపిస్తుంది.

Try It

Try this Python code:

Example

print("Start practicing")
4 + 6

Try It Yourself »

Practice

Practice: Python Interactive Shellలో 12 మరియు 8ను add చేసి resultను చూపించండి. ముందుగా valuesను namesలో store చేసి, తరువాత addition చేయండి.

Hint: first_number మరియు second_number వంటి names ఉపయోగించండి. చివరి lineలో వాటిని + operatorతో కలపండి.

Practice: Interactive Shellలో 7ను 5తో multiply చేసి resultను చూపించండి.

Hint: Multiplication కోసం * operator ఉపయోగించండి.

Practice: Interactive Shellలో print() ఉపయోగించి Hello, Python! అనే textను చూపించండి.

Hint: Textను double quotesలో ఉంచండి.

Common Mistakes

Code ముందు >>> promptను కూడా type చేయడం.

>>> అనేది Python prompt మాత్రమే. Code type చేసేటప్పుడు దాన్ని type చేయకండి.

Python Shellలో code type చేసిన తర్వాత Enter నొక్కకపోవడం.

ప్రతి commandను execute చేయడానికి Enter key నొక్కాలి.

Textను quotes లేకుండా type చేయడం, ఉదాహరణకు print(Hello).

Textను double quotes లేదా single quotesలో ఉంచండి. ఉదాహరణకు print("Hello").

Python Shell నుంచి బయటకు రావడానికి windowను వెంటనే close చేయడం.

Shellలో exit() type చేసి Enter నొక్కండి. అవసరమైతే system-specific shortcutను కూడా ఉపయోగించవచ్చు.

Interactive Shellలో ఒక line execute చేసిన తర్వాత result కనిపించలేదని అనుకోవడం.

కొన్ని assignment lines resultను print చేయవు. Result చూడాలంటే ఆ nameను తరువాతి lineలో type చేయండి లేదా print() ఉపయోగించండి.

Interview Questions

Python Interactive Shell అంటే ఏమిటి?

Answer: Python codeను ఒక్కో lineగా వెంటనే type చేసి execute చేయడానికి ఉపయోగించే environmentను Python Interactive Shell అంటారు.

Python Interactive Shellను REPL అని ఎందుకు అంటారు?

Answer: ఇది codeను Read చేస్తుంది, Evaluate చేస్తుంది, resultను Print చేస్తుంది, తరువాత మళ్లీ input కోసం Loop అవుతుంది. అందుకే REPL అని అంటారు.

Interactive Shellలో Python prompt ఏది?

Answer: సాధారణంగా Python prompt >>>గా కనిపిస్తుంది.

Interactive Shell ఎప్పుడు ఉపయోగకరంగా ఉంటుంది?

Answer: చిన్న calculations, syntax testing, quick experiments మరియు చిన్న commandsను వెంటనే పరీక్షించడానికి ఉపయోగకరంగా ఉంటుంది.

Interactive Shell నుంచి ఎలా బయటకు రావచ్చు?

Answer: exit() type చేసి Enter నొక్కడం ద్వారా బయటకు రావచ్చు.

Exam Questions

Python Interactive Shellలో 6 * 4 type చేస్తే output ఏమిటి?

Answer:

Output 24.

Python Interactive Shell promptను రాయండి.

Answer:

Python Interactive Shell prompt >>>.

Interactive Shell మరియు Python file మధ్య ఒక తేడా ఏమిటి?

Answer:

Interactive Shellలో codeను వెంటనే ఒక్కో lineగా execute చేస్తాము. Python fileలో codeను fileగా save చేసి తరువాత run చేయవచ్చు.

Textను Interactive Shellలో చూపించడానికి ఏ function ఉపయోగిస్తారు?

Answer:

print() function ఉపయోగిస్తారు.

Python Shell నుంచి బయటకు రావడానికి ఉపయోగించే command ఏమిటి?

Answer:

exit() command.

Quick Revision

  • Python Interactive Shellలో codeను ఒక్కో lineగా వెంటనే run చేయవచ్చు.
  • Python Shell prompt సాధారణంగా >>>గా ఉంటుంది.
  • చిన్న calculations మరియు quick experiments కోసం Interactive Shell ఉపయోగిస్తాము.
  • >>> prompt codeలో భాగం కాదు.
  • ప్రతి command తర్వాత Enter నొక్కాలి.
  • exit() ఉపయోగించి Interactive Shell నుంచి బయటకు రావచ్చు.
  • Interactive Shellను REPL అని కూడా అంటారు.

Test Your Knowledge

Take a short quiz based on this lesson.

10 Questions • Results
Scroll to Top