- 1

#3.Write a program to check if the age of a student stored in a tuple is greater than 20 or not

#3.Write a program to check if the age of a student stored in a tuple is greater than 20 or not. #The data stored in the tuple called “student” is the format name, age, qualification, city and values are “Jai”, 20, “Btech”, “Noida”. #Write the code to check the condition - #if the age is greater than 20 print “You are qualified” else print “You are not qualified”

13th Dec 2018, 11:37 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
5 Respuestas
+ 2
This is fine, but in line 9, you can directly write age = Tuple_of_student[1] Also, line 11 is not necessary. And your question says to use the name "student", so use that instead of "Tuple_of_student"
13th Dec 2018, 12:04 PM
Kishalaya Saha
Kishalaya Saha - avatar
13th Dec 2018, 11:39 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
+ 1
You don't have to create an age variable, you can access every element of a tuple by index. if Tuple_of_student[1] >20: ... (Index counting starts with 0.)
13th Dec 2018, 12:07 PM
HonFu
HonFu - avatar
+ 1
Thank you HonFu
13th Dec 2018, 12:10 PM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
Anyone help on this... Kishalaya Saha
13th Dec 2018, 12:00 PM
Thotla Thirupathi
Thotla Thirupathi - avatar