Page 76 - Information_Practice_Fliipbook_Class11
P. 76
Hobby:
Help her complete the task.
Ans. name = input('Enter your name : ')
dob = input('Enter your date of birth as dd-mm-yy : ')
contactNo = input('Enter your contact number : ')
hobby = input('Enter your hobby : ')
print()
print('YOUR DATA')
print()
print('Name : ', name)
print('Date of Birth : ', dob)
print('Contact No: ', contactNo)
print('**********************************************')
print('Hobby : ', hobby)
2. Rahul has written his first program in Python to display the cube of a number. He saved the file as cube.py but the program
could not be executed successfully as it has some errors. Identify the errors and rewrite the correct program.
num = input('Please enter a number')
cube = num * num * num
Print cube
Ans. num is not typecasted to int and print function not used properly.
num=int(input('Please enter a number'))
cube=num * num * num
print(cube)
3. Swastik wants to test the programming knowledge of his friend. He has asked him to write a program to accept distance in
kilometers and display it in miles. His friend finally has written the following program:
miles = int('Enter the value of distance in miles')
kiloMeters = Miles/0.6213
print('miles: ' + miles + 'Kilometers: ' + kiloMeters)
The program written by Swastik's friend is not executing because it has errors. Now Swastik has to identify each error and
explain the same to his friend. Help him complete the task.
Ans. miles = int(input('Enter the value of distance in miles')) # input() was missing
kiloMeters = miles/0.6213 #inconsistent use of uppercase.
print('miles:', miles, 'Kilometers:', kiloMeters)
#comma is to be used to separate values instead of +
4. Gurleen is in class XI. She has taken her unit tests and is awaiting the result. She wants to write a program in Python that
accept marks in three subjects and calculates the average marks. Help her to write the program.
Ans. m1 = int(input('Enter marks in Subject 1 : '))
m2 = int(input('Enter marks in Subject 1 : '))
m3 = int(input('Enter marks in Subject 1 : '))
avgMarks = (m1+m2+m3)/3
print('Average Marks is ', avgMarks)
62 Touchpad Informatics Practices-XI

