Welcome to ZyberPH. Be one of us! Read first our VIP RULES. For more info and guide you. Read our FAQ

Python Programming SERIES: #4

Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Python, Ruby, WML, SQL, XML, and other programming languages.
Post Reply
User avatar
cavin12400
Developer
Developer
Posts: 25
Joined: Wed Apr 06, 2016 12:10 pm
Location: Y̢ǫu͟ ͞c̶a̴n'҉t trac̨k ̡m̡e
Contact:

Python Programming SERIES: #4

Post by cavin12400 »

Hello mga ka Zyber! Medyo naging busy ako lately kaya ngayon lang naka balik.
Thanks nga pala for Admin Androidcribs for the reputation :he:

So last time nag tut ako tungkol sa manipulating variables at iba iba netong types.
Ngayon naman ay kung papano tayo kukuha ng input galing sa user at ano ang sagot ng program or output neto.

START: INPUT/OUTPUT

How's your day? Godbless America. Lol. Anyways ang tut natin ngayon ay tungkol sa paginput ng user.
For example mag input sya ng kanyang name. Medyo tricky ang part na ito or should I say nakaka excite para sa mga baguhan sa programming.
So much for that.

~> So kapag kukuha tayo ng input sa isang user san ba dapat ito mapunta para ma store? It could be into a variable, array, database o di kaya ay nodes.
pero syempre masyado pang advance ang iba kaya naman we will just start from storing the input into a variable. Dont worry we will go in more advance in the near future kaya wag maging ma inip. Iisa lang goal ko dito. Ang masimulan ang programming career ng mga ZERO EXPERIENCE people.
~> So pano tayo magstore sa isang variable galing sa input ng user? Simple lang yan. You just have to follow this syntax:
myVariable = data_type(input("Sentence or Question to be printed to user:"))
~> Ganyan lang ka simple. So what if simple sentence lang or string lang? pwede lang ganito:
myVariable = input("Enter Sentence:")
Image

~> So simple as that diba? Now ano naman ang use neto? Let me say to you na pwedeng e connect ang variable at string sa iisang pagprint lang. Gamit lang kayo ng simpleng comma para gawin eto.
Gawan ko kayo ng example like this:
myVariable = input("Please input your name:")
print("Your name is" , myVariable)
~> So ano ang magiging result nito? Here it goes!!!!
Image

~> Isn't it exciting? HAHAHA Mag experiment na kayo mga ka zyber!
~> So what about if number ang hinihinge ng program?
~> Simple lang din. tignan niyo ang syntax na nilagay ko sa ibabaw. merong data_type. kaya naman parang ganito lang yan:
myVariable = int(input("Enter a number:"))
Image

~> So as what you can see makakakita tayo ng error kapag ang naging input ng user ay hindi pareho sa data type na hinihinge mo sa kanya.
~> So ano exciting dito? Syempre pwedeng pwede kana gumawa ng simpleng calculator mula rito. Isn't it exciting? hahaha
Meron akong example sa inyo:
num1 = int(input("Enter 1st number:"))
num2 = int(input("Enter 2nd number:"))
AnswerADD = num1 + num2
AnswerSUBTRACT = num1 - num2
AnswerDIVIDE = num1 / num2
AnswerMULTIPLY = num1 * num2
print("The sum is:", AnswerADD)
print("The difference is:", AnswerSUBTRACT)
print("The quotient is:", AnswerDIVIDE)
print("The product is:", AnswerMULTIPLY)
Image

~> So ano magiging result neto? RUN NATIN BABY!!
Image

~> SO??? TAMA BA MGA KA ZYBER? Isnt it EXCITING?? So ano pa hinihintay mo? e try mo na at mag experimento!
~> Ang isang magaling na programmer ay nakakalearn mula sa pag experiment. kaya naman kayo na bahala para naman magkaroon kayo ng own niyong basic program!

Leave a thanks or good review or DONATE ang poor ko dre. NEXT>> Python Programming SERIES: #5 (Loop using For Loop)
f**k!
Post Reply

Return to “Programming & Web Design”