CHAPTER 05
Input और Output
User से data लेना और display करना — input(), print()
Advertisement
input() Function
input() से user keyboard से कुछ type कर सकता है। यह हमेशा String return करता है!
python
# Basic input naam = input("आपका नाम: ") print(f"नमस्ते, {naam}! 🙏") # Number input (convert करना जरूरी!) umar = int(input("उम्र: ")) height = float(input("Height (cm): ")) print(f"उम्र: {umar}") print(f"Height: {height:.1f} cm") # Simple calculator a = float(input("पहला number: ")) b = float(input("दूसरा number: ")) print(f"जोड़ = {a+b}") print(f"गुणा = {a*b}")
OUTPUT
नमस्ते, राहुल! 🙏Advertisement
print() के Options
print() में sep और end options से output customize कर सकते हैं।
python
# sep - separator बदलना print("नाम", "राम", sep=" : ") # नाम : राम print(1, 2, 3, sep=" | ") # 1 | 2 | 3 # end - line ending बदलना print("Hello", end=" ") print("World") # Hello World # Special characters print("नाम: राम") # Tab print("Line1 Line2") # New line
OUTPUT
नाम : राम
1 | 2 | 3
Hello World🎯 QUICK QUIZ — Chapter 05
Input क्या है?
Advertisement