You are on page 1of 5

S.

Krish Hariharan 12114


CODE:
#functions
def cont(con):
print("In tabular form:")
print("COUNTRY","\t\t","CAPITAL","\t\t","CURRENCY")
for i in con:
print(i,"\t\t",con[i][0],"\t\t",con[i][1])
print()
name=input("Enter the country's name that you want to know about:")
if name in con:
print("The capital of",name,"is",con[name][0],"and currency is",con[name][1])
else:
print("The country is not in the list!!")
#main program
print("PROGRAM THAT SHOWS COUNTRY, CAPITAL AND CURRENCY
DETAILS IN TABULAR FORM")
n=int(input("Enter the number of countries that you want to add:"))
con={}
for i in range(n):
country=input("Enter your country name:")
cap=input("Enter the capital:")
cur=input("Enter the currency:")
con[country]=cap,cur
cont(con)
OUTPUT:

PROGRAM THAT SHOWS COUNTRY, CAPITAL AND CURRENCY DETAILS IN


TABULAR FORM
Enter the number of countries that you want to add:4
Enter your country name:Spain
Enter the capital:Madrid
Enter the currency:Euro
Enter your country name:Japan
Enter the capital:Tokyo
Enter the currency:Yuan
Enter your country name:China
Enter the capital:Beijing
Enter the currency:Yen
Enter your country name:Cuba
Enter the capital:Havana
Enter the currency:Peso
In tabular form:
COUNTRY CAPITAL CURRENCY
Spain Madrid Euro
Japan Tokyo Yuan
China Beijing Yen
Cuba Havana Peso

Enter the country's name that you want to know about:Spain


The capital of Spain is Madrid and currency is Euro
S. Krish Hariharan 12114
CODE:
#functions
a=b=0
f=open('text.txt','r')
strng=f.read()
l=strng.split()
for i in l:
if i.lower()=="is":
a+=1
elif i.lower()=="the":
b+=1
print("The count of 'is' is",a)
print("The count of 'the' is",b)
f.close()
print()
f=open('text.txt','r')
stng=f.readline()
count=0
for i in strng:
if i[0]=='A':
count+=1
print("The lines starting with A is",count)
f.close()

INPUT: (text.txt)
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets and numbers are allowed in password.
Computer science is easy to learn
Python programming skills is very useful for us.
The united states is one of the largest country

OUTPUT:
The count of 'is' is 6
The count of 'the' is 3

The lines starting with A is 3


S. Krish Hariharan 12114
CODE:
f=open('AI.txt','r')
s=f.readlines()
f.close()
f1=open('AI_1.txt','w')
f2=open('AI_2.txt','w')
for line in s:
if "a" in line:
f1.write(line)
else:
f2.write(line)
f1.close()
f2.close()

INPUT: AI.txt :
AI refers to artificial intelligence
it is the intelligence of machines
with AI machines can perform reasoning and problem solving
AI is the simulation of human intelligence by machines
it is the development in the world technology

OUTPUT:

AI_1.txt :
AI refers to artificial intelligence
it is the intelligence of machines
with AI machines can perform reasoning and problem solving
AI is the simulation of human intelligence by machines

AI_2.txt:
it is the development in the world technology
S. Krish Hariharan 12114
CODE:
f=open("story.txt",'r')
s=f.read()
v=c=u=l=o=0
for i in s:
if i.isalpha():
if i.isupper():
u+=1
if i.islower():
l+=1
if i in "AEIOUaeiou":
v+=1
if i not in "AEIOUaeiou":
c+=1
else:
if i.isspace():
pass
else:
o+=1
print("Vowel count:",v)
print("consonants count:",c)
print("uppercase count:",u)
print("Lowercase count",l)
print("other characters count:",o)
f.close()

INPUT: “story.txt”
Ram lives in #23, NEHRU nagar, New Delhi-400 034. his house is near our school.

OUTPUT:
Vowel count: 22
consonants count: 29
uppercase count: 8
Lowercase count 43
other characters count: 14

You might also like