Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

504 Itc Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

University of Engineering and Technology,

Lahore
(Gujranwala Campus)

Department of Electrical Engineering


ITC Lab Manual

SUBMITTED BY:
SAIFULLAH ISLAM

SUBMITTED TO |
Mam Hira Jamal
Lab #1:
Task 1:
Eliminate all the syntax errors in the following code.

Output:

Task 2:
Write a program that prints the message as shown below

Output:
(a): using multiple print Statement:
(b): using single print statement:

In this we use \n to print on the next line.

Task 3:
Write a programme which output look like the one given below.

koiProgramme:
Output:

Task 4:
Write a program to print the diamond.
Output:
(a): Using multiple print statement:

(b): Using single print Statement:


Task 5:
Write a program to print three diamonds i.e. diamond 1, 2 and 3:

Output:

Lab #2:
Task 1:
Eliminate all the syntax and logical errors in the following code:
Output:

Task 2:
Implement the following programme to find the average of three numbers
entered by the user.
Output:

Task 3:
Write a program that calculates the roots of a quadratic equation. ax2 + bx + c.
Using following formula:
b2-4ac
x = -b ±2a
Output:
©
Task 4:
A right angle triangle having A = 50 metres and C = 10 metres is shown below. Write a
program to find 𝝰 and B.

Output:
Task 5:
Write a program to evaluate the following expression when a=10, b=5, c=15, d=20 and 𝜭 =
45°.

Output:

LAB #3
Task 1:
Eliminate all the syntax and logical errors in the following code:

Output:
Task 2:
Implement the following recipe (algorithm) to find the grade of a student
● If x is greater than 15 then display “The Grade is A”
● If x is less than equal to 15 and greater than 10 then display “The Grade is
B”.
● If x is less than equal to 10 and greater than 5 then display “The Grade is C”.
● If x is less than equal to 5 and greater than equal to 0 then display “The
Grade is F”
Output:

Task 3:
Write a program that takes any number from the user and displays its absolute
value.
Output:
Task 4:
Write a program that takes the coefficients a, b and c of a quadratic equation
ax + bx + c as inputs from the user and then determines the number of roots and
2
the values of the roots.
Output:

Task 5:
Complete the following code to implement the truth table shown below:
X Y X and Y
True True True
True False False
False True False
False False False
Output:
LAB #4
Task 1:
Eliminate all the syntax and logical errors in the following code that displays:

Output:

Task 2:
Implement the following recipe (algorithm) to find the grade of a student
● If x is greater than 15 then display “The Grade is A”
● If x is less than equal to 15 and greater than 10 then display “The Grade is
B”.
● If x is less than equal to 10 and greater than 5 then display “The Grade is C”.
● If x is less than equal to 5 and greater than equal to 0 then display “The
Grade is F”
Task 3:
Complete the following code to implement the truth table shown
below:
X Y X and Y
True True True
True False False
False True False
False False False

Output:

Task 4:
Write a program that stores anything (integer, floating number, string) in variable
x and then determines the type of data stored in x
Task 5:
Write a program that takes four int or float values x1, y1, x2, y2 that represent the
two points (x1, y1) and (x2, y2), and displays the distance between those points as a
float.
Output:

Task 6:
Write a program that takes 6 int or float values that represent the vertices (x1,y1),
(x2,y2), and (x3,y3) of a triangle. The program should print “The triangle is a right-
angle triangle” if the triangle is a right-angle triangle otherwise it should print
“The triangle is not a right angle triangle.
Output:
Task 7:
Write a program that takes three integers i.e. x, bound1 and bound2. The program
should print x if x is between the two bounds, should print the value of bound1 if x
is less than bound1 and should print the value of bound2 if x is greater than
bound2.
Output:

Task 8:
Write a program that works like in 7 but now it is not necessary for Bound1 to be
less than Bound2.
Output:

Task 9:
Write a program that takes 6 numbers (ints or floats) -- x1, y1, r1, x2, y2, r2 . The
program should print “The circles intersect at a single point” if the distance
between the centers of two circles is equal to the sum of their radii. The program
should print “The circles intersect at multiple points”.

Output:
LAB #5
Task 1:
Eliminate all the syntax and logical errors in the following code:

Output:
Task 2:
Write a programme which:
a. Display the message “The absolute is ___” where ___ is the value
stored in x.
b. Prompt the user to enter the number, the absolute of which is to be
found and store it in variable x.
c. If the number is negative, then multiply it by -1 and store it in x.
Output:

Task 3(a):
Write a program that displays “hello world” 5 times using a while-loop.
Output:

©
Task 3(b):
Write a program that displays “Hello World” 5 times with an extra message
of ‘using while loop’ at the top.
Output:

Task 4(a):
Write a program to display all the even numbers from 0 to 50. Use a while-loop.
Output:

Task 4(b):
Write a program to display all the even integers from 0 to 50 and to count and
display the number of even integers.
Output:
Task 4(c):
Write a program to print all the even and odd integers from 0 to 50.
Output:

Task 5:
Complete the following code to display the squares of integers from 1 to 10.
Output:
Task 6:
Write a program that displays all the digits, of any positive number, in reverse
order.
Output:

Task 7:
Write a program to implement the following infinite series to approximate the
value of π.according to following table.

Output:

Task 8:
Write a program that takes 6 integers or float numbers representing three points
(x1, y1), (x2, y2) and (x3, y3). The program should determine whether these points are
the corners of a triangle or not using the triangle-inequality law.

Output:
LAB #6
Task 1:
Using for loop.

Output:

Task 2:
Task 3(a):

Task 3(b):

Task 4(a):

Task 4(b):
Task 4(c):

Task 5:

Task 6:
Write a program that takes any integer from the user and then displays ten
multiples of that integer as shown below
Output:

Task 7:
Write a program that displays the left-most digit of an integer.

Output:
Task 8:
Write a program that continues to take integers from the user until 0 is entered.
The program should then display the sum, the number of integers entered by the
user (other than the 0) and the average of the integers using one print statement.

Output:
LAB #7
Task 1(a) :

Output:

Task 1(b):
After changing 87 88 line.
Output:

Task 2(a)
Output:

Task 2(b):
After changing position of line.
Output:

Task 3:
Complete and eliminate all the errors so that the code determines whether
the number entered by the user is even or odd until the user enters ‘end’

Output:

Task 4:
Write a program to determine the number of 1s, 2s and 3s in a number. Store the
number in a variable as a string and use string indexing technique to solve this
task
Output:
Aslo for input given by user:

Task 5:
. Complete the following program to detect whether a 5 digit number is a
palindrome or not.

Output:
For given input:

Task 6:
Display the digits of a number in reverse order,
Output:
Task 7:
Write a program that determines whether a positive number has consecutive
digits or not.
Output:

Task 8:
Write a program to implement Collatz conjecture.
Output:

Task 9:
Write a program to implement carry-less addition i.e. regular addition, only with
the carry from each column ignored.

Output:
LAB #8
Task 1:
Remove those errors :

Output:

Task 2:
Use a for loop which will be controlled by a variable “x”. It is supposed to run 5
times as there are five line in the triangle.
Output:
Task 3:

Task 4:
Write a program to display all the prime numbers within an interval.
Output:

Task 5(a):
Write a python program to display n-carat diamond. Start programming your
logic/code with the value n=7
.
Output:

Task 5(b):
Design a n carats diamond which is composed of n rows. Here is a 7-carat
diamond.

Output:

You might also like