Learn practical skills, build real-world projects, and advance your career
Created 4 years ago
age={'krishna':41,'agham':18,'digvijay':18,'chandani':21}
for k in age:
print(k,age[k])
inv_age={}
for k in age:
v=age[k]
if v not in inv_age:
inv_age[v]=[k]
else:
inv_age[v].append(k)
print(inv_age)
age={'krishna':41,'agham':18,'digvijay':18,'chandani':21,'priyal':14}
name=['krishna','chandani','agham','priyal']
agelist=[18,21,18,14]
searchname=input()
for i in range(len(name)):
if(name[i]==searchname):
print(agelist[i])
break
print(age[searchname])
# searchage=int(input("find the person with age:"));
# for j in range(len(agelist)):
# if(agelist[j]==searchage):
# print(name[j])
mystr="papa kehte hai, beti engineer banegi"
agelist=[18,21,18,41,18,21]
age={'krishna':41,'agham':18,'digvijay':18,'chandani':21,'priyal':14}
def histogram(s):
hist={}
for i in s:
if i not in hist:
hist[i]=1
else:
hist[i]=hist[i]+1
return hist
print(histogram(mystr))
print(histogram(agelist))
print(histogram(age.values()))
fp=open('lorenz.py')
count_line=0
num_words=0
characters=0
for line in fp:
print(line)
count_line=count_line+1
words=line.split()
print(words)
num_words+=len(words)
print(len(line))
characters=characters+len(line)
print(count_line)
print(num_words)
print(characters)
fp=open('output.txt','w')
fp.write("good morning\n")
fp.write("good afternoon")
fp.close()