Care hospital wants to know the medical speciality visited by the maximum number of patients. Assume that the patient id of the patient along with the medical speciality visited by the patient is stored in a list. The details of the medical specialities are stored in a dictionary as follows:

{
"P":"Pediatrics",
"O":"Orthopedics",
"E":"ENT


Write a function to find the medical speciality visited by the maximum number of patients and return the name of the speciality.

Note: 

  1. Assume that there is always only one medical speciality which is visited by maximum number of patients.

  2. Perform case sensitive string comparison wherever necessary.

Sample Input

Expected Output

[101,P,102,O,302,P,305,P]

Pediatrics

[101,O,102,O,302,P,305,E,401,O,656,O]

Orthopedics

[101,O,102,E,302,P,305,P,401,E,656,O,987,E]

ENT

def max_visited_speciality (patient_medical_speciality_ list,medical_speciality):
result = [0,0,0]
i = 1
while(i< len(patient_medical_speciality_list)):
if patient_medical_speciality_list[i] == 'P': result[0] = result[0] + 1
elif patient_medical_speciality_list[i] == 'O' : result[1] = result[1] + 1
else : result[2] = result[2] + 1
i = i + 2
a = max(result)
a = result.index(a)
if a == 0: speciality = 'Pediatrics'
elif a == 1: speciality ='Orthopedics'
else : speciality = 'ENT'
return speciality
patient_medical_speciality_list= [301,'O',302, 'P' ,305, 'P' ,401, 'E' ,656, 'E']
medical_speciality={"P":"Pediatrics","O":"Orthopedics","E":"ENT"}
speciality=max_visited_speciality (patient_medical_speciality_list,medical_speciality)
print(speciality)




Write a python function, find_correct() which accepts a dictionary and returns a list as per the rules mentioned below.

The input dictionary will contain correct spelling of a word as key and the spelling provided by a contestant as the value.

The function should identify the degree of correctness as mentioned below:
CORRECT, if it is an exact match
ALMOST CORRECT, if no more than 2 letters are wrong
WRONG, if more than 2 letters are wrong or if length (correct spelling versus spelling given by contestant) mismatches.

and return a list containing the number of CORRECT answers, number of ALMOST CORRECT answers and number of WRONG answers. 
Assume that the words contain only uppercase letters and the maximum word length is 10.

Sample Input

Expected Output

{"THEIR": "THEIR", "BUSINESS": "BISINESS","WINDOWS":"WINDMILL","WERE":"WEAR","SAMPLE":"SAMPLE"}

[2, 2, 1]



def find_correct(word_dict):
correct,almost,wrong=0,0,0
for key,value in word_dict.items():
if key == value:
correct=correct+1
else:
if len(key)!=len(value):
wrong=wrong+1
continue
incorrect=0
for i in range(min([len(key),len(value)])):
if key[i] != value[i]:
incorrect=incorrect+1
if incorrect>2:
wrong=wrong+1
break
if incorrect<=2:
almost=almost+1
return [correct, almost, wrong]
word_dict= {"CHECK": "CHEK", "RADIO": "RADICAL", "MIND": "MUND", "VENDOR": "VENDING", "ALWAYS": "ALLISWELL"}
print(find_correct(word_dict))


Write a python function, encrypt_sentence() which accepts a message and encrypts it based on rules given below and returns the encrypted message.
Words at odd position -> Reverse It

Words at even position -> Rearrange the characters so that all consonants appear before the vowels and their order should not change

Note: 

  1. Assume that the sentence would begin with a word and there will be only a single space between the words.

  2. Perform case-sensitive string operations wherever necessary.


Sample Input

Expected Output

the sun rises in the east

eht snu sesir ni eht stea

 

vowels=['a','e','i','o','u']
def encrypt_sentence(sentence):
final=[]
list_sentence = sentence.split(" ")
for index,word in enumerate(list_sentence):
if (index+1)%2!=0:
final.append(word[::-1])
else:
v=[]#to store all vowels
t=[]#to store the letters temporily
for letter in word:
if letter not in vowels:
t.append(letter)
else:
v.append(letter)
t.extend(v)
final.append("".join(t))
#if len(final)>1:
return " ".join(final)
sentence="the"
encrypted_sentence=encrypt_sentence(sentence)
print(encrypted_sentence)
sentence="hello i am omkar"
encrypted_sentence=encrypt_sentence(sentence)
print(encrypted_sentence)




Write a python program to display all the common characters between two strings. Return -1 if there are no matching characters.

Note: Ignore blank spaces if there are any. Perform case sensitive string comparison wherever necessary.

Sample Input

Expected output

"I like Python"
"Java is a very popular language"

lieyon


def find_common_characters(msg1,msg2):
list=[]
for x in msg1:
if x==" ":
continue
else:
for y in msg2:
if x == " ":
continue
elif x == y:
if x in list:
break
else:
list.append(x)
break
output="".join(list)
if len(output)==0:
return -1
else:
return output
#Provide different values for msg1,msg2 and test your program
msg1="moto"
msg2="moto"
common_characters=find_common_characters(msg1,msg2)
print(common_characters)