Learning Python: The Ultimate Guide for Beginners to Coding with Python with Useful Tools



Download 2,02 Mb.
Pdf ko'rish
bet91/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   87   88   89   90   91   92   93   94   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

Chapter 5: User’s Input and Loop
The primary purpose why most programs are written is to solve a particular
problem.  In  order  to  solve  these  problems,  users  must  input  certain
information while interacting with the program. For instance, a player that
determines if someone is eligible to vote or not will require input from the
user.  Such  a  program  will  request  the  user  to  input  their  age,  which  will
enable the program to compare their value with the laid down condition of
the program before displaying the outcome.
In this chapter, you will learn the different ways of accepting input from the
users and how it works. Additionally, you will learn how to prompt users to
provide input by using the input() function. Furthermore, I will guide on the
way  to  keep  your  code  running  using  a  while  loop  pending  when  the
condition becomes false. If you can learn how to ask for input from users
and control how long a program should run, then you can effectively write
interactive programs that will solve many problems.
The simplest means of displaying output on the screen in Python is through
the “print” statement, which allows you to pass expression or zero separated
by  commas.  It  can  also  convert  expressions  passed  through  a  string  and
returns the results. For instance, consider the string below.
print “Learning is part of Life. Python is life”, “Does that sound good?”
When you run the program, your output will be:
Learning is part of Life. Python is life, Does that sound good?
Besides this, python provides two means of accepting keyboard input into
the  program.  You  can  either  use  the  raw_input  function  or  the  input()
function. Let us begin with the input function, as it is the most widely used
input function in Python.



Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   87   88   89   90   91   92   93   94   ...   126




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish