Thursday, February 28, 2019

STRINGS & CONSOLE OUTPUT

STRINGS & CONSOLE OUTPUT

What i did today...

  • When entering a variable, you can just type the word on to the system. String Value goes behind the variable.
  • This code breaks because Python thinks the apostrophe in 'There's' ends the string. So we can do this to fix it: There\'s
  • Each character in a string is assigned a number. This number is called the indexThis is because in Python indices begin counting at 0.
EX:


  • String methods let you perform specific tasks for strings.
  1. 1. len()-output will be the number of characters of strings in the variable. ex: print len(parrot)
  2. 2. lower()-get rid of all the capitalization in your strings.  Enter behind variable in print. ex: print parrot.lower()
  3. 3. upper()-make a string completely upper case. ex: print parrot.upper()
  4. 4. str()-turns non-strings into strings. ex: str(2)-turn 2 into "2"
  5.  5. The % operator after the string is used to combine a string with variables. The % operator will replace the %s in the string with the string variable that comes after it. ex:

What did I learn...

  I learned to use string to do specific tasks in Python Language. The main use of the strings is to organize the words in human language into the language that the computer can read and do work with it. And it is easy for us to read as well comparing to other programming language.

What I'll be doing tomorrow...
  I will be studying about DATE AND TIME in Python language.





No comments:

Post a Comment