First Python Program
First Python Program
Python నేర్చుకోవడం ప్రారంభించేటప్పుడు మొదట ఒక చిన్న program రాయాలి. Python program అనేది Python instructions ఉన్న ఒక file. సాధారణంగా Python file కు .py extension ఉంటుంది.
Python Program అంటే ఏమిటి?
Python లో మనం రాసే instructions ను Python interpreter చదివి execute చేస్తుంది. ఉదాహరణకు, screen పై ఒక message చూపించడానికి print() function ఉపయోగిస్తాం.
మొదటి Python Program ఎలా రాయాలి?
- ఒక text editor లేదా code editor open చేయండి.
- Python code ను type చేయండి.
- File ను
first_program.pyపేరుతో save చేయండి. - ఆ file ను Python interpreter తో run చేయండి.
Program run అయినప్పుడు print() లో ఉన్న text screen పై output గా కనిపిస్తుంది.
Python File మరియు Interactive Shell మధ్య తేడా
Interactive Shell లో code ను ఒక్కో line గా వెంటనే test చేయవచ్చు. Python file లో మాత్రం మొత్తం program ను save చేసి, అవసరమైనప్పుడు మళ్లీ run చేయవచ్చు. చిన్న scripts మరియు పెద్ద programs కోసం Python files ఉపయోగకరంగా ఉంటాయి.
ఎక్కడ ఉపయోగిస్తారు?
Python programs ను calculations, text processing, automation, websites, data analysis మరియు అనేక ఇతర పనుల కోసం ఉపయోగిస్తారు. ప్రతి పెద్ద project కూడా చిన్న, సులభమైన programs తోనే ప్రారంభమవుతుంది.
Simple Explanation
మొదటి Python program లో సాధారణంగా print() function ఉపయోగిస్తాం. print() screen పై information చూపిస్తుంది. మనం code ను .py file లో save చేసి run చేస్తే, Python ఆ instruction ను చదివి output చూపిస్తుంది.
ఈ lesson లో ముఖ్యమైన విషయం: code రాయడం, file గా save చేయడం, run చేయడం, output చూడడం.
Real-Life Example
మీరు ఒక greeting card తయారు చేస్తున్నారని ఊహించండి. Card పై Hello! అని రాస్తే, దాన్ని చదివే వ్యక్తికి ఆ message కనిపిస్తుంది. అదే విధంగా Python లో print() ఉపయోగించి ఒక message రాస్తే, program run చేసినప్పుడు ఆ message computer screen పై కనిపిస్తుంది.
Code Examples
మొదటి Python Program
print("Hello, Python!")
ఈ program screen పై Hello, Python! అనే message ను చూపిస్తుంది. ఈ code ను first_program.py అనే file లో save చేసి run చేయవచ్చు.
Hello, Python!
Line-by-Line Explanation
print() function screen పై information చూపించడానికి ఉపయోగిస్తారు. Quotes లో ఉన్న Hello, Python! text ను Python చదివి output గా display చేస్తుంది. Program execute అయిన వెంటనే ఈ line message ను screen పై చూపిస్తుంది.
Try It
Try this Python code:
print("Welcome to Python!")
Practice
Practice: ఒక Python program రాయండి. అది screen పై I am learning Python! అనే message ను చూపించాలి. Code ను practice.py file లో save చేసి run చేయండి.
Hint: print() function ను ఉపయోగించి text ను double quotes లో రాయండి.
Practice: మీ పేరు screen పై కనిపించేలా ఒక Python program రాయండి. ఉదాహరణకు, output లో My name is Ravi. లాంటి message చూపించండి.
Hint: print() లో మీ message ను English characters తో రాయండి.
Common Mistakes
print తర్వాత parentheses పెట్టకపోవడం. ఉదాహరణ: print"Hello".print() ను సరైన parentheses తో రాయండి: print("Hello").
print(Hello).Screen పై చూపించాల్సిన text ను quotes లో రాయండి:
print("Hello").
.py extension లేకుండా save చేయడం.File ను
first_program.py వంటి పేరు మరియు .py extension తో save చేయండి.
Opening మరియు closing quotes రెండూ ఉండేలా చూసుకోండి. Function పేరు
print అని చిన్న అక్షరాలతో రాయండి.
Interview Questions
Python లో screen పై text చూపించడానికి ఏ function ఉపయోగిస్తారు?
Answer: print() function ను ఉపయోగిస్తారు.
Python file యొక్క సాధారణ extension ఏమిటి?
Answer: Python file యొక్క సాధారణ extension .py.
క్రింది code ఏమి చేస్తుంది: print("Hi")?
Answer: ఇది screen పై Hi అనే text ను చూపిస్తుంది.
Exam Questions
Python లో మొదటి program గా సాధారణంగా ఏ function ను ఉపయోగిస్తారు?
Answer:
print() function ను ఉపయోగిస్తారు.
Python program ను file గా save చేయడానికి ఏ extension ఉపయోగించాలి?
Answer:
.py extension ఉపయోగించాలి.
print("Good Morning") code యొక్క output ఏమిటి?
Answer:
Output: Good Morning
Quick Revision
print()function screen పై output చూపిస్తుంది.- Python program ను సాధారణంగా
.pyextension తో save చేస్తారు. - Text ను quotes లో రాయాలి.
- Python file ను save చేసి run చేస్తే output కనిపిస్తుంది.
- Interactive Shell లో ఒక్కో line test చేయవచ్చు; Python file ను మళ్లీ మళ్లీ run చేయవచ్చు.
