Pyhon Assignment 15
Pyhon Assignment 15
In [4]: #WAP
#List = ['hyd','mumbai','chennai']
# op = ['HYD','MUMBAI','CHENNAI']
List = ['hyd','mumbai','chennai']
l=[a.upper() for a in List]
print(l)
In [24]: # WAP
#List = ['hyd','mumbai','chennai']
# op = ['Hyd','Mumbai','Chennai']
List = ['hyd','mumbai','chennai']
l=[a.capitalize() for a in List]
print(l)
In [23]: #WAP
#List = ['hyd','mum#bai','chen#nai']
# op = ['Mum#bai','Chen#nai']
['mum#bai', 'chen#nai']
In [25]: #WAP
#List = ['hyd','mum#bai','chen#nai']
# op = ['hyd']
['hyd']
In [30]: # Q7):
# input:
# string1='[email protected], [email protected],
# [email protected]'
# output
# fnames=['virat','Rohit','Dhoni']
# sname=['kohli,sharma,Mahendar']
# cname=['rcb','Mi','Csk']
file:///C:/Users/Shubham/Downloads/Pyhon_assignment_15.html 1/3
24/08/2024, 22:13 Pyhon_assignment_15
print('fnames:', fnames)
print('sname:', sname)
print('cname:', cname)
In [31]: # Q8) string1='can canner can you can not canner can be can'
# Get the count of each word in above string in a list
# o.p: ['can-5','canner-2','you-1','not-1','be-1']
string1 = 'can canner can you can not canner can be can'
words = string1.split()
word_count = {}
for word in words:
if word in word_count:
word_count[word] += 1
else:
word_count[word] = 1
import random
max_value = numbers[0]
min_value = numbers[0]
print("Maximum:", max_value)
print("Minimum:", min_value)
file:///C:/Users/Shubham/Downloads/Pyhon_assignment_15.html 2/3
24/08/2024, 22:13 Pyhon_assignment_15
# list_ans= ['Modi','Rohit',29]
# step-1: Iterate each qn
# step-2: ask the user enter the answer for corresponding qn
# step-3: match that answer with list_ans
# Note: Make sure first qns ans match with first index of the ans
# step-4: if both are match give the one mark
# step-5: Finally print how many qns are correct
# how many marks got
list_qns = ['Who is PM of India?', 'Who is ICT ODI captain?', 'How many states a
list_ans = ['Modi', 'Rohit', 29]
score = 0
for i in range(len(list_qns)):
user_ans = input(list_qns[i] + " ")
if user_ans == list_ans[i]:
score += 1
In [ ]:
file:///C:/Users/Shubham/Downloads/Pyhon_assignment_15.html 3/3