|
🙋‍♂️ Python Input Function එක | 4වෙනි පාඩම 💬

🙋‍♂️ Python Input Function එක | 4වෙනි පාඩම 💬

technology programming
By Rasanjana 2025-05-07 19:52:25

👋 සුභ දවසක් guys!

අද Python lesson එක input ekak program එකට denne kohomada kiyala.

ඒකට Python වල තියෙනවා special function එකක්: input() 🧠

📥 input() කියන්නේ මොකක්ද?

🗣️ input() කියන්නේ user kenekta ahala response එකක් ගන්න Python method එකක්.

name = input("ඔයාගේ නම කියන්න: ")
print("Hello", name)

💡 මෙහිදී:

  • input() → user එකට ප්‍රශ්නයක් දාන්න
  • name → user එක enter කරන value එක save වෙන්නේ මෙහි

🖨️ Output:

ඔයාගේ නම කියන්න: Jake
Hello Jake

🎯 Example: වයස ගැන ප්‍රශ්නයක්

age = input("ඔයාගේ වයස කීයද? ")
print("ඔයා", age, "වයසක් තියෙනවා!")

🔎 නෝට් එකක්: input() එකෙන් ගන්න හැම data එකම string (str) එකක් විදිහට එනවා.

🔁 Number input එකක් ගන්න නම්?

📌 දශම නැති number (int) → int(input())

📌 දශම තියෙන number (float) → float(input())

age = int(input("ඔයාගේ වයස? "))
print("ඔයාට තවත් අවුරුදු 5කට පස්සේ", age + 5, "වයසයි 😄")

👀 මෙහිදී int() එකෙන් string එක number එකක් වෙනවා.

🧠 Real Life Example: Calculator පොඩ්ඩක්

num1 = float(input("Number 1: "))
num2 = float(input("Number 2: "))

total = num1 + num2
print("එකතුව:", total)

🖨️ Output:

Number 1: 5.5  
Number 2: 6.5  
එකතුව: 12.0

🔒 Bonus Tip:

ඔබට input එකක් ගත්තාමම ඒක variable එකක් විදිහට store කරගන්න ඔනෙ. නැත්තං ඒක පසුව print කරන්නවත් math karannaවත් බැහැ 😅

🧪 Challenge එක:

👇 මෙක try karapan machan:

  • ඔයාගෙ නම input එකෙන් ගන්න
  • ඔයාගෙ age input එකෙන් ගන්න
  • ඒවා print කරන්න:
Hello Jake! You're 21 years old. 😎

Use this structure:

name = input("ඔයාගේ නම: ")
age = input("ඔයාගේ වයස: ")

print("Hello", name + "! You're", age, "years old. 😎")

🏁 අද මතක තියාගන්න:

  • input() → userගෙන් දේවල් අහන්න
  • හැම input එකම default වශයෙන් string 🧵
  • Number input එකක් නම් int() / float() වලින් convert කරන්න

🔜 Next Episode:

🧠 ඉස්සරහට අපි බලමු conditionsif, else කියන decision-making stuff!

🛣️ “ඔයා 18ට වැඩිද? එහෙනං ඔයා exam එකට eligible!” කියන වගේ logic walata ready wenna 😎

📣 Comment ekak dagena yamu❤️

Next one danna ready da?

Rasanjana

Rasanjana

Member since 2025-04-09 13:55:06

Comments

Please login to post a comment.

No comments yet. Be the first to comment!