Formatting Strings | Python for Beginners [11 of 44]

preview_player
Показать описание


#microsoftdeveloper #pythonforbeginners #learntocode
Рекомендации по теме
Комментарии
Автор

Thanks for pulling these together. Viewers: Note that "output" is a variable that must be printed using print(), and not (as might be interpreted by newbies, like me) an intrinsic Python function.

SirBraxton
Автор

I am 11 years old and I am learning Python and I totally get it. I understand everything in Python now.

IloveQuran
Автор

In older tutorials on YouTube, you will also see people doing this:
output = 'Hello, %s %s' % (first_name, last_name)

"%s" means string, you have two strings first name and last name. And to determine their order you write "% (first_name, last_name)". It is important to know though that this is discouraged nowadays. I'm only mentioning it here, in case you come across any other tutorial which doesn't use any of the upper methods.

It is also useful to know that using the + method (concatenation) or the f'Text{} {}' (f-strings) are the fastest ones. Lastly, the f-strings only work in Python 3.6 and later versions.

onee
Автор

PSA: f-strings are actually only in Python 3.6 and newer

jonaro
Автор

0:01 Python methods.
2:00 Numbers representing elements of the string.
3:00 Python 3 method for string concatenation.

HECTORARTUROA
Автор

Thank you for the video.
I have 2 string exercises which are making me hate programming with python from the heart as they are suppose to be as easy as returning 1+1.
def pairs(txt):
if len(txt)%2==0:
right_indexes=list(range(1, len(txt), 2))
print(right_indexes)
left_indexes=list(range(0, len(txt), 2))
print(left_indexes)
right_letters=map(list(txt).__getitem__, right_indexes)
left_letters=map(list(txt).__getitem__, left_indexes)
pairs=list(zip(left_letters, right_letters))
return pairs
I've ended up creating this list of paired tuples thinking it might help me understand better as I noticed how comparing 2 things next to each other. Because if the number of things is odd at the right side edge, it's not easy for me to know what to do.

But it's not helping me to solve these very simple problems as I have no idea how to implement a for or while loop from pairs [(A, B), (B, C), (A, B), (C, C), (C, D)] for these 2 exercises:

1)Make a function that removes letters that are alone. Like if you have like ABBCABCCCD it would return BBCCC

2)Make another function which does the opposite turning like ABBCABCCC returns ACABD removing duplicates alight together (not just all).

my brain only works to turn the whole thing into a set... ;____; When things are like this and you truly have to understand loops.... plus conversion as one is suppose to input a string and output should be a string.... I really feel like I'm the dumbest person alife

Please help me solve these.

ugabuga
Автор

I learn python from Mexico, thanks Microsoft

franciscoreyess.
Автор

"output =" doesnt work on visual studio. it has no color and it shows no output in the terminal. I am a bit confused.

ashnabwad
Автор

This is an alternative to using %s ryt?
For eg:
(name, age) = ('xyz', 20)
sent = 'Hello %s, of age %d'
print(sent%(name, age))

sridharsrinivasan
Автор

Heads up, for python 3.8 at least. The F at the beggining need to be capitalized

robertopena
Автор

The videos are great and the people doing them are wonderful as well :-)! It is only really difficult to listen to the high pitched voice at the beginning of every sentence.

SleepyAnt-oybl-wj
Автор

I personally love f-string more than my video games.

grandempiretang
Автор

No output for the below code :


my_name=input('What is your Name: ')
my_sirname=input('What is your Sirname: ')
output= 'Hello, {0} {1}'.format(my_name, my_sirname)
output=f'Hello, {my_name} {my_sirname}'

jyotirmoyroy
Автор

Why did he jump like that at the beginning?

GenX-Memories
Автор

I am listening to the tutorial and I really appreciate the contents, but Christopher is using his voice at times in a very high pitch (non bass) way that makes it difficult to listen to for long. The woman's voice has a lower note than him, it's the speaking style. So Christopher, if possible for future recordings can you bear that in mind?

renderdreality
Автор

Typical MSFT! Introduce a new function, Output and Not mention what that is!! OMG!!

pradeeprajurs