Answers for "{} string python"

48

formatted string python

# Newer f-string format
name = "Foo"
age = 12
print(f"Hello, My name is {name} and I'm {age} years old.")
# output :
# Hello, my name is Foo and I'm 12 years old.
Posted by: Guest on March-27-2020
4

pyhon string

# defining strings in Python
# all of the following are equivalent
my_string = 'Hello'
print(my_string)

my_string = "Hello"
print(my_string)

my_string = '''Hello'''
print(my_string)

# triple quotes string can extend multiple lines
my_string = """Hello, welcome to
           the world of Python"""
print(my_string)
Posted by: Guest on February-21-2021
3

{} string python

txt1 = "My name is {fname}, I'm {age}".format(fname = "John", age = 36)
txt2 = "My name is {0}, I'm {1}".format("John",36)
txt3 = "My name is {}, I'm {}".format("John",36)

#https://www.w3schools.com/python/ref_string_format.asp
Posted by: Guest on January-23-2021
11

strings in python

#A string is a type of data. There are many data types. It can be manipulated.
#It can be storerd as a variable
myString = "Hello world"
#WE can print it:
print(myString)
#You can append it to arraY:
myArr = []
myArr.append(myString)
#You can find the index of a character in a string:
H = myString[0]
#You can use methods on it:
lowercase = myString.lower()
#You can convert it into a integer provided it is a numerical string
myInt = int(myString)
#So thats the basics, hope i haven't left anything out.
Posted by: Guest on July-26-2020
2

define a string in python

string1 = "something"
string2 = 'something else'
string3 = """
something
super
long
"""
Posted by: Guest on December-04-2020
-1

python string

print("Hello")

print('Hello')
Posted by: Guest on May-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language