Professional Documents
Culture Documents
Section 1
Program 1
X = 1025
Print(type(x))
Program 2
X = 10.25
Print(type(x))
Program 3
X = False
Print(type(x))
Program 4
X = ‘false’
Print(type(x))
Program 5
X = 10+25j
Print(type(x))
Program 6
Income = 450
Tax = 0.32
Print(income * tax)
Program 7
age = input(“How old you are ?”)
print(“Your age is ”, age)
Print(“your father age is”, age+35)
Program 8
Print(“your name is %s” %’sansa’)
Print(“your name is %r” %’sansa’)
Program 9
Print(“your account balance is %s” %5678.25)
Print(“your account balance is %d” %5678.25)
Program 10
Print(“your account balance is %5.3f” %5678.25625)
Print(“your account balance is %5.0f” %5678.25625)
Print(“your account balance is %1.0f” %5678.25625)
Print(“your account balance is %1.5f” %5678.25625)
Print(“your account balance is %15.0f” %5678.25625)
Print(“your account balance is %25.2f” %5678.25625)
Program 11
Print(“first: %s, Second: %5.2f, Third: %r”
%(“hi”,5678.25625,”bye!”)
Print(“first: %s, Second: %5.2f, Third: %r, finally: %d”
%(“hi”,5678.25625,”bye!”,5678.25625)
Program 12
Print(“Hii my name is {}”.format(“Targarean”))
Print(“myself {0}, {3} of {1} kingdoms, my
{2}”.format(“sansa”, 7, “grace”, “Queen”)
Program 13
Print(“First: {a}, Second: {b}, Third: {c}”.format(a=1, b=
‘TWO’, c = 165.245))
Program 14
Print(“A %s saved is a %s earned” %(“penny”,”penny”))
Print(“A {p} saved is a {p} earned”.format(p = ‘penny’))
Program 15
Print(“{0:8} | {1:9}”.format(‘penny’,”Coursack”))
Print(“{0:8} | {1:9}”.format(‘penny’,123.))
Print(“{0:8} | {1:9}”.format(‘Cousack’,321))
Program 16
Print(“{0:<8} | {1:^8} | {2:>8}”.format( ‘left’,”Center”,
‘Right’))
Print(“{0:<8} | {0:^8} | {0:>8}”.format(123))
Program 17
Print(“{0:-<8} | {1:+^8} | {2:*>8}”.format(
‘left’,”Center”, ‘Right’))
Print(“{0:@<8} | {0:!^8} | {0:.>8}”.format(123))
Program 18
Print(“Lucky Number: %10.2f”%143.5789)
Print(“Lucky Number: {0:10.2f}”.format(143.5789))
Program 19
Name = “Coursack”
Print(f“This company name is {Name}”.)
Program 20
Name = “Coursack”
Print(f“This company name is {Name!r}”.)
Program 21
num = 6525.235678
Print(f“Lucky Number is :”{num:{20}.{6}})
Program 22
Class myclass(object):
’’’The Class’s docstring’’’
def my_method(self):
’’’The method’s docstring’’’
def my_function(self):
’’’The function’s docstring’’’
Help(myclass)
Program 23
Print(“{:>10}”.format(“test”))
Program 24
Print(“%-10s”%(“test”,))
Program 25
Print(“%.5s”%(“Hello_world”))
Print(“{:.5}”.format(“Hello_World”))
Program 26
Print(“%06.2f”%(3.141592653589793))
Print(“{:06.2f}”.format(3.141592653589793))
Program 27
Print(‘{:=5d}’.format((-23)))
Print(‘{:=+5d}’.format((23)))
Print(‘{:=+5d}’.format((-23)))
Program 28
Person={“first”: “Arya_stark”, “last”: “Dracarus”}
Print(“{p[first]}{p[last]}”.format(p = person))
Program 29
Data = [4,8,69,105,256,234,55]
Print(“{p[4]}{p[5]}”.format(p = Data))
Program 30
Print(“{:.{prec}} = {:.{prec}f}”.format(“coursack”,
2.7182, prec=”.3”))
Section 2
Program 1
Using f-string method:
Output: My 10 character, four decimal number is:
23.46
Given: num = 23.45678
Program 2
Using .format method:
Output: Left==== | -Center- | ...Right
101===== | ---222--- | ......118
Program 3
Using .format method:
Output: -----coursack-----
Program 4
Using “%” method:
Output: softw {5 padding after “w”}
Input : “software_solutions”
Program 5
Using .format & ‘%’ method:
Output: 003.14
Input: 3.141592653589793
Program 6
Using .format method:
Output: +00003.14
Input: 3.141592653589793
Program 7
Using f-string method:
Output: Hi Hari. You are a student. You were in jntuk.
Input: name="Hari"
profession = "student"
affiliation = "jntuk"