Professional Documents
Culture Documents
INPUT :
OUTPUT:
2. Format string
age=input(“”)
height=input(“”)
weight=(“”)
print(f”{}”)
INPUT :
OUTPUT :
INPUT :
OUTPUT:
4. Format string #2
print("mary had a little lamb.")
print("its fleece was white as{}. ".format(' snow'))
print("."*10)
INPUT :
OUTPUT:
5. Concatenation
End1=”C”
End2=”H”
End3=”E”
End4=”E”
End5=”S
End6=”E”
End7=”B”
End8=”U”
End9=”R”
End10=”G”
End11=”E”
End12=”R”
Print(End1+ End2+End3+ End4+ End5+ End6+ End7+ End8+ End9+ End10+ End11+End12)
INPUT :
End1="I"
End2="N"
End3="D"
End4="E"
End5="P"
End6="E"
End7="N"
End8="D"
End9="E"
End10="N"
End11="T"
print(End1+ End2+End3+ End4+ End5+ End6+ End7+ End8+ End9+ End10+ End11)
OUTPUT:
INDEPENDENT
>>>
6. Formatter
Formatter= “{} {} {} {}”
Print(formatter.format(1,2,3,4)
Print(formatter.format(one, two , three, four)
Print(formatter.format(True, False, False, True)
Print(formatter.format(formatter, formatter, formatter, formatter)
Print(formatter.format(“Try your”,
“own text”,
“here maybe a poem”,
“or a song about fear”,
))
INPUT :
def main () :
formatter= "{} {} {} {}"
name="MUHAMMAD WAQAR KHAN"
print(name)
print(formatter.format(1,2,3,4))
print(formatter.format("one", "two" , "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format("MY NAME",
"IS WAQAR",
"AND I AM",
"18 YEARS OLD",
))
main ()
OUTPUT:
7.Format string #3
P=____’=>’
Print(“How old are you?”, end=’’)
Age=input(f’{p}’)
Print(“how tall are you?”, end=’’)
Height=input()
Print(“How much do you weight”, end=’’)
Weight=input()
Print(f”so you are {} old, {} tall and {} heavy”)
INPUT :
OUTPUT: