Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming



Download 2,61 Mb.
bet41/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   37   38   39   40   41   42   43   44   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

CHALLENGE QUESTION


This week’s challenge is to test your ability to read code. I want you to read the code block and think about whether it will work or not. If you believe it will not work, I want you to make a note of why it won’t. It’s important to be able to both read and write:
>>> print('{} is my favorite sport'.format(element))
>>> element = 'Football'
After you’ve written down your answer, go ahead and run the code within a cell. If your answer was incorrect, try to analyze where you why. The answer will be at the end of this chapter.

© Connor P. Milliken 2020
C. P. Milliken, Python Projects for Beginners, https://doi.org/10.1007/978-1-4842-5355-7_3
ChApTer 3 User InpUT And CondITIonAls
Monday: User Input and Type Converting
In today’s lesson we’ll introduce the ability to interact with the user and a concept called type conversion. These will be necessary to understand how to build the calculator at the end of the week.
To follow along with the content for today, let’s open up Jupyter Notebook from our
python_bootcamp” folder. Once it’s open, create a new file, and rename it to “Week_03.” Next, make the first cell markdown that has a header saying: “User Input & Type Converting.” We’ll begin working underneath that cell.

Accepting User Input


In many programs we’ll be creating, you’ll need to accept user input. To do so, we need to use the input() function. Like the print function, input will print the string inside of the parenthesis, but it will also create a box for the user to enter information. Let’s look at an example:

# accepting and outputting user input print( input("What is your name? ") )

Go ahead and run that cell. You’ll notice that the cell will output whatever you write within the box. When the interpreter comes across the input function, it will pause until enter is pressed.
Note Information entered is taken into the program as a string.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   37   38   39   40   41   42   43   44   ...   200




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