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

TM:20

ASSIGNMENT 01
CS14950 AK

Instructions:
1. You must submit individual code files for every question. Your files should be
named as follow:
<Your_Roll_No.>_CS14950_<AsgnNo>_<Question_Number>.py
For example: 21PY124_CS14950_Asgn02_Q2a.py
2. You must submit the code file in the following link:
www.CS14950_A1.com

Question 01: [5 mks]


Given an integer N, print all the prime numbers P such that P<N.
Sample:
Input: 9
Input-Type: Int
Output: [2,3,5,7]
Output-Type: List
0 marks if no output/runtime error.

test case 01:


input: 9
output: [2,3,5,7]
partial output: 0.5
total output: 1

test case 02:


input: 25
partial output: 0
complete output: 2

test case 03:


input: 100
partial output: 0
complete output: 2
Question 02: [7+8]
a. Given a string in the form ‘54grams.’, print two lines as follows:
1. First line must give the measurement in metric system (lb., in.,
ft., F) .
2. Second line must give the measurement in SI units(kg, m, oC).
Sample:
Input: ‘54grams.’ Input-Type: str
Ouput:
54 grams in metric is: 0.119lbs.
54 grams in SI units is: 0.054kgs.
Output-Type: str
 Input can be in the following types: ‘grams, kgs, lbs, fts,
in., m., cms, F, K(kelvin), oC.’
 Use of library functions are allowed.

b. Solve problem Q2a without using any library functions.


For part a: For part b:

0 for no output. 0 for no output.


0 if line does not read like 0.5/1 if line does not read like
'54 grams in -- is: --' '54 grams in -- is: --'

test case 01: test case 01:


input: '98grams' input: '98grams'
outputs line01: 1.0 outputs line01: 1.0
outputs line02: 1.0 outputs line02: 1.0

test case 02: test case 02:


input: '12ft' input: '12ft'
outputs line01 in in: 1.0 outputs line01 in in: 1.0
outputs line01 in ft. 0.5 outputs line01 in ft. 0.5
outputs line02: 1.0 outputs line02: 1.0

test case 03: test case 03:


input: '98K' input: '98K'
outputs line01: 1.0 outputs line01: 1.0
outputs line02: 1.0 outputs line02: 1.0

test case 04: test case 04:


input: '1125cms' input: '1125cms'
outputs line01: 0.5 outputs line01: 0.5
outputs line02: 0.5 outputs line02: 0.5

You might also like