0% found this document useful (0 votes)
70 views4 pages

CCS 3275 Scientific Computing Cat 2-1

The document contains a student examination record listing 7 students who took the CCS 3275: Scientific Computing exam in December 2021 at Meru University of Science & Technology. It also contains 9 questions on topics related to scientific computing and Python programming. The questions cover programming paradigms in Python, functional vs object-oriented programming, machine learning frameworks, data types in Python, CSV file handling in Python, and the power of Pandas for data analysis.

Uploaded by

samson oino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views4 pages

CCS 3275 Scientific Computing Cat 2-1

The document contains a student examination record listing 7 students who took the CCS 3275: Scientific Computing exam in December 2021 at Meru University of Science & Technology. It also contains 9 questions on topics related to scientific computing and Python programming. The questions cover programming paradigms in Python, functional vs object-oriented programming, machine learning frameworks, data types in Python, CSV file handling in Python, and the power of Pandas for data analysis.

Uploaded by

samson oino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MERU UNIVERSITY OF SCIENCE & TECHNOLOGY

CCS 3275: SCIENTIFIC COMPUTING

Bachelor of Science in Mathematics and Computer Science Y3S1 Cat 2

Date: December-2021 Time: 1 hours

Dennis Mwangi Sc205/101014/19

George Wachira Sc205/101033/19

Paul Mwangi Sc205/101035/19

Maureen Wanjagi Sc205/101049/19

Maureen Wanjiru Sc205/101027/19

Michael Murimi Sc205/101026/19

Joseph Wainaina Sc205/101022/19


1. Discuss three types of Programming paradigms that Python supports (3marks)

 Object Oriented Programming – objects are the key element of the paradigm
and the codes are re-usable.
 Functional Programming – everything is bind in pure mathematical functions
style and it uses declarations over statements
 Procedural Programming – a series of computational steps are divided to
modules i.e the code is grouped in functions and the code is serially
executed step by step.

2. Explain why Functional programming is important in python programming and


differences with Object Oriented programming (4marks)

 The paradigm focuses more on what to solve rather than how to solve hence
helping solve a problem effectively in a simpler way.
i. Functional programming follows declarative programming model
whereas OOP does follows imperative programming
ii. Functional programming uses recursion for iteration while OOP uses
loops for iteration
iii. OOP has access specifiers i.e public, private and protected whereas
functional programming does not have any access specifier.
iv. Functional programming supports parallel programming, OOP on the
other hand does not support parallel programming.

3. Identify the two classes of I/O functions and distinguish between them using
relevantexamples in program segments. (4marks)

 The print() function


>>> X = 8
>>> Y = 6
>>> Z = X+Y
>>> print(Z)
 Input() function
>>>car = input(“Name your car model: “)
Name your car model: Audi
>>>print (“My car model is “. Audi)
My car model is Audi

4. Discuss the framework of Machine Learning in data analytics (4marks)

 Scikit-Learn: used to run quick ML model sketches to see if a model might


have some interpretability
 TensorFlow: runs on both CPUs and GPUs and is designed to perform
regression, classification and neural networks
 Keras: a neural network library built on top of TensorFlow to make ML
modelling straightforward
 Huggingface.co: creates a good base models researchers built on top of
TensorFlow and PyTorch
5. Design an algorithm and a flow chart that computes the cosine of an angle if input
is indegrees (4marks)

 math.cos
Import math
A = math.pi/6
Print (“Value pi/6 is : “,end = “”)
Print(math.cos(A))

6. Explain four types of data types in Python (4marks)

 Sequence Type – ordered collection of similar or different data types e.g


string, list
 Set – an unordered collection of datatype that is iterable
 Boolean – datatype with one of the two built in values, True or False
 Dictionary – an unordered collection of datatype that is iterable, mutable
and has no duplicate elements.

7. Explain how to write CSV files in Python (4marks)

 Open the CSV file for writing (W mode) by using the open() function
 Create a CSV writer object by calling the writer() function of the CSV module
 Write data to CSV file by calling the Writerow() or Writerows() method of the
CSV writer object.
 Close the file once you complete writing data to it

8. What is the output of the program segment? Explain by tracing the segment
(2marks)
# Python program explaining
# bitwise_or() function
import numpy as geek
in_num1 = 10
in_num2 = 11
print ("Input number1 : ", in_num1)

print ("Input number2 : ", in_num2)

out_num = geek.bitwise_or(in_num1, in_num2)

print ("bitwise_or of 10 and 11 : ", out_num)

 numpy.bitwise_or () function is used to Compute the bit-wise OR of


two array element-wise. This function computes the bit-wise OR of
the underlying binary representation of the integers in the input
arrays.
The output will be:
Input number1 : 10

Input number2 : 11

bitwise_or of 10 and 11 : 11

9. Explain why Pandas are the most powerful data analysis tool in Python
Programming and scientific computing

Pandas is powerful and easy to use on open source tool specifically used
for data analysis and manipulation. Pandas is built on the Numpy package
and its key data structure is called the dataframe. Pandas is mainly used for
data manipulation, visualisation of the data, building machine learning
tools etc. There are two main data structures in pandas that is series and
daraframes.

Series is a one dimensional array defined in pandas that can be used to


store any data type.

Dataframes is a 2D data structures containing rows and columns

You might also like