1# Newer f-string format
2name = "Foo"
3age = 12
4print(f"Hello, My name is {name} and I'm {age} years old.")
5# output :
6# Hello, my name is Foo and I'm 12 years old.
1# defining strings in Python
2# all of the following are equivalent
3my_string = 'Hello'
4print(my_string)
5
6my_string = "Hello"
7print(my_string)
8
9my_string = '''Hello'''
10print(my_string)
11
12# triple quotes string can extend multiple lines
13my_string = """Hello, welcome to
14 the world of Python"""
15print(my_string)
1#A string is a type of data. There are many data types. It can be manipulated.
2#It can be storerd as a variable
3myString = "Hello world"
4#WE can print it:
5print(myString)
6#You can append it to arraY:
7myArr = []
8myArr.append(myString)
9#You can find the index of a character in a string:
10H = myString[0]
11#You can use methods on it:
12lowercase = myString.lower()
13#You can convert it into a integer provided it is a numerical string
14myInt = int(myString)
15#So thats the basics, hope i haven't left anything out.
1txt1 = "My name is {fname}, I'm {age}".format(fname = "John", age = 36)
2txt2 = "My name is {0}, I'm {1}".format("John",36)
3txt3 = "My name is {}, I'm {}".format("John",36)
4
5#https://www.w3schools.com/python/ref_string_format.asp
1string1 = "something"
2string2 = 'something else'
3string3 = """
4something
5super
6long
7"""