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


Using Methods to Change Case in String



Download 2,02 Mb.
Pdf ko'rish
bet22/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   18   19   20   21   22   23   24   25   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

Using Methods to Change Case in String
One simple task you can perform when using strings is to change the case
of  a  particular  word.  What  do  you  think  the  output  will  be  for  the  code
below?
Full_name = “johnson boris”


print(full_name.title())
Once  you  write  the  code,  save  the  file  as  name.py  before  running  it.  The
output will be as follow:
Johnson Boris
If  you  observe,  the  variable  full_name  refers  to  the  string  in  lowercase
“johnson  boris.”  After  the  variable  name  comes  to  the  method  title().  In
Python, a method is an action upon which certain manipulation can be taken
on  a  piece  of  data.  Furthermore,  the  dot  (.)  that  comes  after  the  variable
name informs the interpreter to allow the title() method to interact with our
variable  name.  parentheses  always  follow  a  method  because  they  require
additional information to perform their function. The function of the title()
method  is  to  change  the  first  letter  of  each  word  to  capital  letter.
Furthermore,  Python  allows  us  to  change  string  to  all  lowercase  or
uppercase.
Full_name = “Johnson Boris”
print(full_name.lower())
print (full_name.upper))
The output will be as follows:
johnson boris
JOHNSON BORIS

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   18   19   20   21   22   23   24   25   ...   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