You are on page 1of 4

Introduction to PROGRAMMING CSE 101 Sunday, Feb 11, 2024

Kingdom of Saudi Arabia ‫المــمـــــــــلكــــة العـربية الســــــعودية‬


Royal Commission at Yanbu
‫بــينبع الـــــــهـــــــــــيـــــئة الملــــــكـــــــية‬
Colleges & Institutes Division
‫قــــطـــاع الـكــــــــــــلــيات والـمــعــاهـد‬
Yanbu Industrial College ‫كـــــلية ينبع الصناعية‬
Computer Science & Engineering Dept. ‫قسم علوم وهندسة الحاسب األلي‬

ASSIGNMENT 1

ACADEMIC YEAR 1445/1446 H (2023/2024 G), SEMESTER II (452)

INTRODUCTION TO PROGRAMMING
CSE 101
START TIME: 04:00 PM
DATE: Monday, February 12, 2024
FINISH TIME: 19-02-2024
STUDENT NAME: _________________________________________________________

STUDENT ID: SECTION:


FOR INSTRUCTOR USE ONLY GENERAL INSTRUCTIONS

Q. No. CLOs
MAX MARKS  Write your name and I.D. number in the space
MARK OBTAINED
1 2.1 5 provided above.
2  Do not use pencils for answering except for drawing.
3
 Read each question carefully before answering.
4
5  Number shown on the right-hand side against each
5.00 question is the mark allocated.
TOTAL MARKS

MARKED BY: Qaiser Awan Signature:

CHECKED BY: Signature:

Page 1 of 4
Introduction to PROGRAMMING CSE 101 Sunday, Feb 11, 2024

[Task 1]
Write a program code that Calculate the floor division of two integers 0.5 Mark

num1=int(input('Enter first number:'))


num2=int(input('Enter second number:'))
div=num1//num2
print("Floor division of two integers=",div)

[Task 2]
Write a program code that Calculate the power of an integer. Example (num) n 0.5 Mark

base=int(input('Enter the base number:'))


exp=int(input('Enter the exponent:'))
print("Power of",base,"to",exp,"is",base**exp)

[Task 3]
Write Python code to perform the following basic math functions: 1.0 Mark
a. Calculate the absolute value of “num= -3.8” find the answer upto
two decimle places
Output:
The absolute value of -3.8 upto two decimle place is = 3.80

num=-3.8
result=round(abs(num),2)
print("The absolute value of",num,"upto two decimle place is =", result)

Page 2 of 4
Introduction to PROGRAMMING CSE 101 Sunday, Feb 11, 2024

b. Round a given floating-point number to the nearest integer.


Output:
Enter a floating-point number: 4.7
Rounded value: 5

num=float(input('Enter a floating-point number: '))


result=round(num)
print("Rounded value:", result)

c. Write a code to find the maximam and minimaum value of [150, 75, 49, 55, 133]
Output:
Maximum value: 150
Minimum value: 49

num=[150, 75, 49, 55, 133]


print("Maximum value: ", max(num))
print("Minimum value: ", min(num))

[Task 4] Write the following program code. 3.0 Marks


i. Write two input statement that ask the user to input value into variable “name”
and “marks”, then enter the following values
Enter name: Ahmed
Enter Marks: 75.50
ii. Write a conditional statement using if – else marks>= 60 display the following
message (Name and Marks should display from varibale)
Output

Page 3 of 4
Introduction to PROGRAMMING CSE 101 Sunday, Feb 11, 2024

name=input('Enter name: ')


mark=round(float(input('Enter marks: ')))
print('Hello!')
if mark>=60:
print('',name,' You score',mark,'% Marks. (Pass) Congradulation.')
else:
print('',name,' You score',mark,'% Marks. (Fail) better luck next time.')

Page 4 of 4

You might also like