Computer Science, asked by atahrv, 7 months ago

Please answer this if you know python.

Attachments:

Answers

Answered by ıtʑFᴇᴇʟɓᴇãᴛ
24

\mathtt{\huge{\underline{\red{Programme:-}}}}

Programming Language :- ★ Python

{\Python " : 3

tprice = 0

tup = [[1.'Raman','2'OPD','5600'],[2.'Shiva','6','Private'12000']]

f= open(filename,'w')

g= open('recpt.txt','r')

lines = g.readlines()

for line in lines:

base = line.split()

tup.append(base)

print('S.no','\t','Patients Name ','\t','No.of day','\t',' Room ','\t','Price')

for i in range(len(tup)):

if len(tup[i][0]) <= 7:

print([i+1],'\t',tup[i][0],'\t','\t',tup[i][2],'\t',tup[i][1])

else:

print([i+1], '\t', tup[i][0], '\t', tup[i][2],'\t',tup[i][1])

price = int(tup[i][1])

tprice += price

print(tprice)

\mathtt{\huge{\underline{\green{Output:-}}}}

S.no|PatientsName|No.of day|Room|Price

1. ____Raman ______2.___OPD.__5600

2. ____Shiv _____6.___Private.__12000

__________________________________

Answered by itzcupycake
4

Programming Language :- ★ Python ★

{\Python " : 3

tprice = 0

tup = [[1.'Raman','2'OPD','5600'],[2.'Shiva','6','Private'12000']]

f= open(filename,'w')

g= open('recpt.txt','r')

lines = g.readlines()

for line in lines:

base = line.split()

tup.append(base)

print('S.no','\t','Patients Name ','\t','No.of day','\t',' Room ','\t','Price')

for i in range(len(tup)):

if len(tup[i][0]) <= 7:

print([i+1],'\t',tup[i][0],'\t','\t',tup[i][2],'\t',tup[i][1])

else:

print([i+1], '\t', tup[i][0], '\t', tup[i][2],'\t',tup[i][1])

price = int(tup[i][1])

tprice += price

print(tprice)

\mathtt{\huge{\underline{\green{Output:-}}}}

Output:−

S.no|PatientsName|No.of day|Room|Price

1. ____Raman ______2.___OPD.__5600

2. ____Shiv _____6.___Private.__12000

Similar questions