CBSE Class 11 Computer Science Question 47 of 48

Python Programming Fundamentals — Question 47

Back to all questions
47
Question

Question 34

Write a program to read details like name, class, age of a student and then print the details, firstly in the same line and then in separate lines.

Solution
name = input("Enter name of student: ")
c = int(input("Enter class of student: "))
age = int(input("Enter age of student: "))
print("Name:", name, "Class:", c, "Age:", age)
print()
print("Name:", name)
print("Class:", c)
print("Age:", age)
Output
Enter name of student: Kavya
Enter class of student: 9
Enter age of student: 14
Name: Kavya Class: 9 Age: 14

Name: Kavya
Class: 9
Age: 14
Answer

name
=
input
(
"Enter name of student: "
)
c
=
int
(
input
(
"Enter class of student: "
))
age
=
int
(
input
(
"Enter age of student: "
))
print
(
"Name:"
,
name
,
"Class:"
,
c
,
"Age:"
,
age
)
print
()
print
(
"Name:"
,
name
)
print
(
"Class:"
,
c
)
print
(
"Age:"
,
age
)
Output
Enter name of student: Kavya
Enter class of student: 9
Enter age of student: 14
Name: Kavya Class: 9 Age: 14

Name: Kavya
Class: 9
Age: 14