0% found this document useful (0 votes)
7 views

Comp930 Fall 2024 assignment #1.pdf

Uploaded by

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

Comp930 Fall 2024 assignment #1.pdf

Uploaded by

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

COMP 930

Assignment#1
Weightage 10% Due Date :::

Programming 2
INSTRUCTOR: Parwinder Kaur
CLASS: Comp 930

Instructions
 Read all questions carefully.
 Partial marks are not awarded.
 Avoid Using Chat GPT.
 No cell phones permitted.
 No sharing of information between students.

DATE:
STUDENT NAME:
STUDENT NUMBER:

Task 1) The simplest encryption algorithm! (mark 5%)


A Caesar cypher is a weak form of encryption that involves “rotating” each letter by
a fixed number of places. To rotate a letter means to shift it through the alphabet,
Alpha college of Business and
Technology
wrapping around to the beginning if necessary, so ’B’ rotated by 2 is ’D’ and ’Z’ rotated
by 2 is ’B’. To rotate a word, rotate each letter by the same amount. For example,
“cheer” rotated by 7 is “jolly”.

Fun fact: In the movie 2001: A Space Odyssey, the ship computer is called HAL,
which is IBM rotated by -1.

Write a function called ceaser_cypher that takes a string and an integer as parameters,
and returns
a new string that contains the letters from the original string rotated by the given
amount.

Hint: You might want to use the built-in function which converts a character to a
numeric code, and converts numeric codes to characters.
Constrains: You will need to differentiate between upper and lowercase characters. For
example, If A is rotated by, it will become C(upper-case), but if a is rotated by 2, it will
become c (lower-case).

Task -2) Binary Search Algorithm Implementation in Python (mark5%)


Binary search is one of the most common algorithms for finding items in sequential data
types such as a list. Here is a good introduction and pseudo-code for this algorithm.
Write a function in Python that takes a list of integers, and a specific integer and uses
binary search to find if the desired integer is present in the list. If the integer is present,
the function will return True, otherwise, it will return False. Print the result value. And
location of result value as well.
https://www.khanacademy.org/computing/computer-science/algorithms/binary-
search/a/implementing-binary-search-of-an-array

Alpha college of Business and


Technology
Task-3) Formula Implementation (mark 5%)
It is important to mention that as Python developers, you will need to convert a lot of
mathematical formulas to Python codes. This specific part is dedicated to make sure you
are able to just do that!
The mathematician Srinivasa Ramanujan found an infinite series that can be used to
generate a numerical approximation of 1/π:

Write a function called estimate_pi that uses this formula to compute and return an
estimate of π. It should use a while loop to compute terms of the summation until the
last term is smaller than
1e-15, which is Python notation for 10−15 .
Hint: To implement factorial, you can use
https://docs.python.org/3/library/math.html#math.factorial

4. Read the following flow chart and write down the script? 5 marks

Alpha college of Business and


Technology
QQ5

Print following Square pattern with the help of loops? 5 marks

Hints
character = '#' # The symbol to print
numRows = 7 # The number of rows
space = ' ' # The space character

# Iterate over the rows.

# Each row includes 2 more columns


# than the row number.

# Print the symbol in the first


# and last column.
Alpha college of Business and
Technology
# Add spaces between symbols.

# Go to the next row.

Pattern:

Q6
Create a script for the following flowchart? 5 Marks

Alpha college of Business and


Technology
Output should be as given below

Alpha college of Business and


Technology
Alpha college of Business and
Technology
Q7:# Print results Discount Amount and total Amount
# Constants for the increase in tuition per year,
# and the starting tuition amount.
INCREASE_PER_YEAR = 0.2
STARTING_AMOUNT = 9100.0

# Declare a variable to store the tuition.


tuition = STARTING_AMOUNT

# Calculate and print amount of increase each year for atleast 10


years.

Print Increased fee and Tuition Fee


8: Create a mountain and inside the mountain set up a moon . mountain in blue color and moon
in white color all rest background in black color

Submit Python Code and screenshot of Python code and execution in a PDF or Word
File (StudentNumber_Groupnumber_assignment.PDF),please make sure you put at
least three screenshots (one for each part)

Note: Replace StudentNumber with your student ID. For example, if your student id is
C071234567 your compressed file should be called C071234567.zip or C071234567.rar
Deadline: Please refer to the deadline indicated on the assignment page
Task 1 The Program woks Some parts The Program
successfully of program does not work
Full Marks work (For NO Marks
example
Question
number 4
have 3
parts . First
works but
second and
third does
not work
then
student
will get
marks for
first part it
Alpha college of Business and
Technology
ould be
2+2+1)
Task 2 The Program woks Some parts The Program
successfully of program does not work
Full Marks work NO Marks
Task 3 The Program woks Some parts The Program
successfully of program does not work
Full Marks work NO Marks
Task 4 The Program woks Some parts The Program
successfully of program does not work
Full Marks work NO Marks
Task 5 The Program woks Some parts The Program
successfully of program does not work
Full Marks work NO Marks
Task 6 The Program woks Some parts The Program
successfully of program does not work
Full Marks work NO Marks

Alpha college of Business and


Technology
Alpha college of Business and
Technology

You might also like