Some Questions and Answers using Lists in Python.

 User_name=input('Enter your name,User:')                                                                       #Welcoming Statement

print("Welcome dear "+User_name+"\n\n1.Please guess the following patterns and check their answers below.")


Question_1=['_','25','125','625']                                                               #Question1

print(Question_1)

Question_2=['7','21','35','49','_','77','91','_','119']

print(Question_2)                                                                                 #Question2

Question_3=['10','90','170','250']

print(Question_3)                                                                                   #Question3


input("Press 'Enter' key to see the answer.")


print("\nAns.The answers are as follows:-")

Question_1.remove("_")

Question_1.insert(0,'5')                                                                 #Answer for question1

print(Question_1)

Question_2.remove("_")

Question_2.remove("_")

Question_2.insert(4,'63')                                                              

Question_2.insert(7,'105')

print(Question_2)                                                                     #Answer for question2

Question_3.append(330)                                                         

print(Question_3)                                                                     #Answer for question3



input("Press 'Enter' key to go for 2nd Question.")



print("\n\n2.Change the gender in the following sentences:-")

Sentence_1=['A','boy','is','eating','his','apple.']                                          #Sentence1

print(Sentence_1)

Sentence_2=['An','apple','is','eaten','by','him.']                                          #Sentence2

print(Sentence_2)

Sentence_3=['An','apple','was','given','to','him','by','his','father.']                  #Sentence3

print(Sentence_3)



input("Press 'Enter' key to see the answer.")



print("\n\nAns.The answers are as follows:-")

##(Sentence_1.pop(1))

##(Sentence_1.pop(4))                                                   #Correct method but can confuse the programmer while editing again.

##(Sentence_1.insert(1,'girl'))                                          #Because popping index once change evryone's index and programmer will 

##(Sentence_1.insert(4,'her'))                                           find difficulty in popping other indexes after that.

##print(Sentence_1)


(Sentence_1.remove('boy'))

(Sentence_1.remove('his'))

(Sentence_1.insert(1,'girl'))

(Sentence_1.insert(4,'her'))

print(Sentence_1)                                     #Answer for the statement1

(Sentence_2.remove('him.'))

(Sentence_2.insert(5,'her.'))

print(Sentence_2)                                     #Answer for te statement2

(Sentence_3.remove('him'))

(Sentence_3.remove('his'))

(Sentence_3.remove('father.'))

(Sentence_3.insert(5,'her'))

(Sentence_3.insert(7,'her'))

(Sentence_3.insert(8,'mother.'))

print(Sentence_3)                                     #Answer for the statement3


print("\n\n\t\tThank You "+User_name+' for attending this questions.')           #Program ends.

Comments

Some of my more interesting posts...

Questions on Conjunctions(English Grammer) by using string methods

Voting Eligibility of a person & Calculating their name No. using if/else in Python