Variables are reserved memory locations to store values. Variables can be of several data types. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc.
Variable Assignment
Unlike other programming langues variables need not be assigned in advance. In Python create a variable, you just need to assign a variable and then start using it. Assignment is done with a single equals sign ‘=’

If u want to change then you got to assign it to a new value

Rules for naming a variable
- All variable names must begin with an alphabet, an underscore, or a dollar sign ($).
- After the first initial letter, variable names may contain letters & digits 0 to 9. No spaces or special characters are allowed.
- The variable name can be of any length.
- Spaces are not allowed
- Variable names are case sensitive.
- Keywords cannot be used.
String
String is nothing but sequence of characters. String in python are enclosed with single quotes (”) and double quotes (“”).

When you want to assign multi line string we have to use three quotes (“”” “””).

String Manipulations
- String indexing: String can be accessed like arrays. The first character has the position 0.

- Sub string: We can create a sub string by using a colon.
Syntax = variable[start_position : end_position].
If there’s no start or end position python assumes that its the first character or the last character.

- Length : Its used to find the length of a string.

- Count : Its used to count the number of times a given word occurs in a string.

- Capitalize : It converts all the first character of a string to uppercase letter and lowercase all other characters, if any.

- String Operators : It possible to add and multiply strings. Strings in Python are immutable. They cannot be modified after being created.

- String Methods : Many basic string manipulation tasks can be handled with built-in methods like upper, lower, strip,split…etc
- Upper: Converts all the characters to upper case.
- Lower: Coverts all the characters to lower case.
- Strip: Removes extra whitespace from the beginning or the end.
- Split: It will convert the string to a list.

- String Formatting : This method is used to format a string. Each string object has access to the format method, which allows substituting values into the string at designated locations.

Follow the blog for more interesting topics.
Author : Nivedita.M
Edited by: Arcot Gautham

Great stuff! I always forget you can multiply strings. Have you ever found any good use cases for that feature?
LikeLike
hello sir, yeah we can use multiply strings like
str = “name.\n” + \
“is.\n” + \
“noun.”
any example i hope you understood
LikeLiked by 1 person
Sir, really sorry for the delay reply and could you share this blog for us please!
LikeLike