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


Multi-Line String When Using input() Function



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

Multi-Line String When Using input() Function
At times, when writing a program, the prompt you wanted to write may exceed a line. For instance,
you may decide to tell your user whey you are requesting the specific information from them. In this
situation, you can assign the message to a variable before passing the variable to the input() function.
With this method, you can build numerous prompts through different lines. Let us use an example to
illustrate it:
message = “Please tells us your full name, to enable us to provide a personalized message.”
message += “\nWrite your full name”
full_name = input(message)
print(f “\Welcome, {full_name}!”)
This example simply shows you a way of building a multi-line string. In the first line, we assign the
variable  message  with  the  information  we  want  the  user  to  respond  to.  however,  the  second  line
included the += operator to take the first string stored in a message and attach it with this second
one. With this, our message spans two lines. When you run the program, you should have something
like this, depending on the name you insert.
Please tells us your full name to enable us to provide a personalized message.
Write your full name
Welcome, Amanda Norman!
You  can  include  as  many  messages  you  want  on  different  lines.  You  can  begin  by  practicing  this
little  exercise.  Create  a  Python  program  that  allows  you  to  write  a  multi-line  string  with  input
requests for the names of your family members.

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   90   91   92   93   94   95   96   97   ...   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