Professional Documents
Culture Documents
LAB # 03
OBJECTIVE
Taking input from user and controlling output position.
EXERCISE
A. Point out the errors or undefined/missing syntax, if any, in the following python
programs.
1. print("Hello \b World!")
There is no error.
(Str) causing the error.If we use (int) instead of (str) the program will run.
3. age = 23
message = "Happy " + age + "rd Birthday!" print(message)
The sum(+) causing the error if we use comma(,) instead os sum(+) the program
will run.
1. a=5
print("a =", a, sep='0', end=',')
Output:
>> %Run 'lab 3 B1.py'
a =05,
Output:
>> %Run 'lab 3 b2.py'
Enter Employee Name:Imran
Enter salary:100000
Enter Company name:Imran Shabeer Construction Company
**Printing Employee Details**
Name Salary Company
Imran 100000 Imran Shabeer Construction Company
3. n1=int(input('"enter n1 value'))
n2=int(input('enter n2 value'))
Output:
>>> %Run 'lab 3 b3.py'
"enter n1 value10
enter n2 value50
1. Write a program to print a student’s bio data having his/her Date of birth, Roll no,
Section, Percentage and grade of matriculation and Intermediate. All the fields
should be entered from the console at run time.
Code:
print("\t\t\t\t**Bio Data**\n")
print("\t\t\t *Personal Profile*\n")
FullName=str(input("Enter Full Name\t\t:\t"))
FatherNam=str(input("Enter Father Name\t\t:\t"))
D_O_B=(input("Enter date of birth\t\t:\t"))
Roll_no=(input("Enter roll no \t\t\:\t"))
Sec=str(input("Enter Section\t\t:\t"))
Per_in_Matric=str(input("Enter Percentage in Matric\t:\t"))
Per_in_Inter=str(input("Enter Percentage in Inter\t:\t"))
print("\n")
print("Full Name =\t\t\t:\t",FullName)
print("Father Name =\t\t\t:\t",FatherNam)
print("Date Of Birth =\t\t\t:\t",D_O_B)
print("Section =\t\t\t\t:\t",Sec)
print("Matric Percentage =\t:\t",Per_in_Matric)
print("Inter Percentage =\t:\t",Per_in_Inter)
Output:
> %Run 'lab 3 biodata.py'
**Bio Data**
*Personal Profile*
2. Write a program that asks the user what kind of food they would like. Print a
message about that food, such as “Let me see if I can find you a Chowmein”. Food
name must be in uppercase. (hint: use upper( ) for food name)
Code:
Food_name=input("What kind of food do you like")
print("let me see if i can find you a",Food_name.upper())
Output:
>>> %Run 'lab 3 food web.py'
What kind of food do you likebiryani
let me see if i can find you a BIRYANI
3. Take the marks of 5 courses from the user and calculate the average and percentage,
display the result:
Eachcourse=50 marks
Total_marks=
course1+course2+course3+course4+course5
average=Total_marks/5 percentage=(Total_marks x
100)/250
Code:
print("\t\tProgram to display Exam results")
Pf=int(input("Enter your Pf Number:"))
Itc=int(input("Enter your itc Number:"))
English=int(input("Enter your English Number:"))
Islamiat=int(input("Enter your Islamiat Number:"))
Math=int(input("Enter your Math Number:"))
print("Each course has maximum 50 marks")
Totalmarks=Pf+Itc+English+Islamiat+Math
average=Totalmarks/5
print("average=",average)
percentage=(Totalmarks*100)/250
print("percentage=",percentage)
Output: