CT2 SET 2
CT2 SET 2
No
SRM Institute of Science and Technology
Faculty of Engineering and Technology
Slot F, Batch 1
SRM Institute of Science and Technology SET 2
OFF LINE
College of Engineering and Technology
CYCLE TEST – II
Academic Year: 2022-2023 (EVEN Semester)
Way 1 :Messaging
⚫ puts(" Type your Message / Instruction ");
⚫ Like Printf Statement puts() can be used to display
message.
Way 2 : Display String
⚫ puts(string_Variable_name) ;
Notes or Facts :
⚫ puts is included in header file “stdio.h”
⚫ As name suggest it used for Printing or Displaying
Messages or Instructions.
Reg.No
SRM Institute of Science and Technology
Faculty of Engineering and Technology
10 Write a python program to calculate simple interest 4 2 4 4
print("Enter the Principle Amount: ")
p = int(input())
print("Enter Rate of Interest (%): ")
r = float(input())
print("Enter Time Period: ")
t = float(input())
si = (p*r*t)/100
print("\nSimple Interest Amount: ")
print(si)
11 Write a Python program to find the average of 5 numbers using while loop 5 2 4 4
n = 5
total_numbers = n
sum = 0
while n >= 0:
sum += n
n -= 1
print("sum =", sum)
# Output sum =
OR
12 Compare User defined functions and built in functions in C with one example 3 2 4 10
b.
Library / built-in functions User-defined functions
These functions are predefined in a These functions are not predefined rather it is defined
header file or preprocessor directive. by user according to the requirements.
These functions can be simply used by These functions should be declared, defined and
including respective header file. called in order to use.
Since, these functions are predefined Since, these functions should be defined by the user
programs are short. programs are lengthy.
Program execution time is faster. Program execution time is slower.
It simplifies the program. Using more user-functions increase complexity.
Eg, strlen( ), strcmp( ), strcpy( ), strcat( ) Eg, fact( ), average( ), greatest( ), anyname( )
Reg.No
SRM Institute of Science and Technology
Faculty of Engineering and Technology
13 a. Krishnan borrowed Rs. 23,500 from a bank to buy a scooter at a rate of 6.8% p.a., 4 2 4 10
compounded yearly. What amount will she pay at the end of 2 years and 2 months to
clear the loan? Therefore, could you help her to pay the correct amount by writing C
program to find the solution?
Program 6- mark
Formula -2Mark
Output- 2Mark
OR
13 Explain the basic list operations with examples. 4 1 2 10
b. Arithmetic Operators
Comparison Operators
Assignment Operators
Bitwise Operators
Logical Operators
Membership Operators
14 a. Explain python libraries with examples 5 1 2 10
1. TensorFlow: This library was developed by Google in collaboration with the Brain
Team. It is an open-source library used for high-level computations. It is also used in
machine learning and deep learning algorithms. It contains a large number of tensor
operations. Researchers also use this Python library to solve complex computations in
Mathematics and Physics.
2. Matplotlib: This library is responsible for plotting numerical data. And that’s why it is
used in data analysis. It is also an open-source library and plots high-defined figures like
pie charts, histograms, scatterplots, graphs, etc.
3. Pandas: Pandas are an important library for data scientists. It is an open-source machine
learning library that provides flexible high-level data structures and a variety of analysis
tools. It eases data analysis, data manipulation, and cleaning of data. Pandas support
operations like Sorting, Re-indexing, Iteration, Concatenation, Conversion of data,
Visualizations, Aggregations, etc.
OR
14 Explain the three types of indexing method in Numpy with suitable example. 5 1 2 10
b. Contents of ndarray object can be accessed and modified by indexing or slicing, just like Python's
in-built container objects.
items in ndarray object follows zero-based index. Three types of indexing methods are available
− field access, basic slicing and advanced indexing.
Basic slicing is an extension of Python's basic concept of slicing to n dimensions. A Python slice
object is constructed by giving start, stop, and step parameters to the built-in slice function.
This slice object is passed to the array to extract a part of array.
ndarray object is prepared by arange() function. Then a slice object is defined with start, stop,
and step values 2, 7, and 2 respectively. When this slice object is passed to the ndarray, a part
of it starting with index 2 up to 7 with a step of 2 is sliced.