[go: up one dir, main page]

0% found this document useful (0 votes)
13 views17 pages

Modified College Project Updated

Odisha junction of the day of the day is a great day and I want to see you ever wondered why you should be computer science e e asache apni ki mam ko bhi theek h na ho to kya hua hai baas kotha bolbe nah aber hai ki nahi hai ki tum 12 hai to sell your personal account number theke tomake chai bole

Uploaded by

gamerarya95
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)
13 views17 pages

Modified College Project Updated

Odisha junction of the day of the day is a great day and I want to see you ever wondered why you should be computer science e e asache apni ki mam ko bhi theek h na ho to kya hua hai baas kotha bolbe nah aber hai ki nahi hai ki tum 12 hai to sell your personal account number theke tomake chai bole

Uploaded by

gamerarya95
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/ 17

PROJECT FILE

IDC COMPUTER SCIENCE

SUBJECT: IDC- COMPUTER SCIENCE

ROLL: [Your Roll Number]

REGISTRATION NUMBER: [Your Registration Number]

SEM: 1

Sample Project COURSE: IDC

Teacher's Signature: ________________

Page 1
Assignment 2

TABLE OF CONTENTS

Assignment 1: Write a Python Program to Solve Quadratic Equation.

Assignment 2: Write a Python Program to Check Leap Year.

Assignment 3: Write a Python Program to Check Prime Number.

Assignment 4: Write a Python Program to Print the Fibonacci sequence.

Assignment 5: Write a Python Program to Check Armstrong Number.

Assignment 6: Write a Python Program to Convert Decimal to Binary, Octal, and Hexadecimal.

Assignment 7: Write a Python Program to Find HCF or GCD.

Assignment 8: Write a Python Program to Find the Factors of a Number.

Assignment 9: Write a Python Program to Make a Simple Calculator.

Assignment 10: Write a Python Program to Interchange First and Last Elements in a List.

Sample Project
Assignment 11: Write a Python Program to Find the Sum of Elements in a List.

Assignment 12: Write a Python Program to Find the Smallest Number in a List.

Assignment 13: Write a Python Program to Print Current Date and Time.

Assignment 14: Write a Python Program to Display Calendar.

Assignment 15: Write a Python Program to Solve Quadratic Equation.

Teacher's Signature: ________________

Page 2
Assignment 3

ASSIGNMENT 1

QUESTION:

1. Write a Python Program to Solve Quadratic Equation.

ANSWER:

# Solve the quadratic equation ax**2 + bx + c = 0

import cmath

a = 1

b = 5

c = 6

Sample Project
d = (b**2) - (4*a*c)

sol1 = (-b-cmath.sqrt(d))/(2*a)

sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solutions are:', sol1, sol2)

OUTPUT:

The solutions are: (-3+0j), (-2+0j)

Teacher's Signature: ________________

Page 3
Assignment 4

ASSIGNMENT 2

QUESTION:

2. Write a Python Program to Check Leap Year.

ANSWER:

year = int(input("Enter a year: "))

if (year % 400 == 0) and (year % 100 == 0):

print(year, "is a leap year")

elif (year % 4 == 0) and (year % 100 != 0):

print(year, "is a leap year")

else:
Sample Project
print(year, "is not a leap year")

OUTPUT:

2020 is a leap year

Teacher's Signature: ________________

Page 4
Assignment 5

ASSIGNMENT 3

QUESTION:

3. Write a Python Program to Check Prime Number.

ANSWER:

num = int(input("Enter a number: "))

flag = False

if num == 0 or num == 1:

print(num, "is not a prime number")

elif num > 1:

Sample Project
for i in range(2, num):

if (num % i) == 0:

flag = True

break

if flag:

print(num, "is not a prime number")

else:

print(num, "is a prime number")

OUTPUT:

7 is a prime number

Teacher's Signature: ________________

Page 5
Assignment 6

ASSIGNMENT 4

QUESTION:

4. Write a Python Program to Print the Fibonacci sequence.

ANSWER:

nterms = int(input("How many terms? "))

n1, n2 = 0, 1

count = 0

if nterms <= 0:

Sample Project
print("Please enter a positive integer")

elif nterms == 1:

print("Fibonacci sequence up to", nterms, ":", n1)

else:

print("Fibonacci sequence:")

while count < nterms:

print(n1)

nth = n1 + n2

n1 = n2

n2 = nth

count += 1

OUTPUT:

Fibonacci sequence: [0, 1, 1, 2, 3]


Teacher's Signature: ________________

Page 6
Assignment 7

ASSIGNMENT 5

QUESTION:

5. Write a Python Program to Check Armstrong Number.

ANSWER:

num = int(input("Enter a number: "))

sum = 0

temp = num

while temp > 0:

digit = temp % 10

Sample Project
sum += digit ** 3

temp //= 10

if num == sum:

print(num, "is an Armstrong number")

else:

print(num, "is not an Armstrong number")

OUTPUT:

153 is an Armstrong number

Teacher's Signature: ________________

Page 7
Assignment 8

ASSIGNMENT 6

QUESTION:

6. Write a Python Program to Convert Decimal to Binary, Octal, and Hexadecimal.

ANSWER:

n = int(input("Enter a number: "))

b = bin(n)

o = oct(n)

h = hex(n)

Sample Project
print("The decimal value of", n, "is:")

print(b, "in binary.")

print(o, "in octal.")

print(h, "in hexadecimal.")

OUTPUT:

10 in binary: 0b1010, in octal: 0o12, in hexadecimal: 0xa

Teacher's Signature: ________________

Page 8
Assignment 9

ASSIGNMENT 7

QUESTION:

7. Write a Python Program to Find HCF or GCD.

ANSWER:

def compute_hcf(x, y):

if x > y:

smaller = y

else:

smaller = x

for i in range(1, smaller + 1):

Sample Project
if (x % i == 0) and (y % i == 0):

hcf = i

return hcf

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

num2 = int(input("Enter second number: "))

print("The H.C.F. is", compute_hcf(num1, num2))

OUTPUT:

The H.C.F. is 6

Teacher's Signature: ________________

Page 9
Assignment 10

ASSIGNMENT 8

QUESTION:

8. Write a Python Program to Find the Factors of a Number.

ANSWER:

def print_factors(x):

print("The factors of", x, "are:")

for i in range(1, x + 1):

if x % i == 0:

print(i)

Sample Project
num = int(input("Enter a number: "))

print_factors(num)

OUTPUT:

The factors of 12 are: [1, 2, 3, 4, 6, 12]

Teacher's Signature: ________________

Page 10
Assignment 11

ASSIGNMENT 9

QUESTION:

9. Write a Python Program to Make a Simple Calculator.

ANSWER:

def add(x, y):

return x + y

def subtract(x, y):

return x - y

Sample Project
def multiply(x, y):

return x * y

def divide(x, y):

return x / y

print("Select operation:")

print("1.Add")

print("2.Subtract")

print("3.Multiply")

print("4.Divide")

while True:

Teacher's
choice Signature: ________________
= input("Enter choice(1/2/3/4): ")
Page 11
if choice in ('1', '2', '3', '4'):
Assignment 12

ASSIGNMENT 10

QUESTION:

10. Write a Python Program to Interchange First and Last Elements in a List.

ANSWER:

list = [1, 2, 3, 4, 5]

list[0], list[-1] = list[-1], list[0]

print("List after swapping first and last elements:", list)

Sample Project
OUTPUT:

List after swapping first and last elements: [5, 2, 3, 4, 1]

Teacher's Signature: ________________

Page 12
Assignment 13

ASSIGNMENT 11

QUESTION:

11. Write a Python Program to Find the Sum of Elements in a List.

ANSWER:

a = [10, 20, 30, 40]

s = 0

for val in a:

s += val

print(s)

Sample Project
OUTPUT:

Sum of elements: 100

Teacher's Signature: ________________

Page 13
Assignment 14

ASSIGNMENT 12

QUESTION:

12. Write a Python Program to Find the Smallest Number in a List.

ANSWER:

a = [8, 3, 5, 1, 9, 12]

smallest = a[0]

for val in a:

if val < smallest:

smallest = val

Sample Project
print(smallest)

OUTPUT:

Smallest number in list: 1

Teacher's Signature: ________________

Page 14
Assignment 15

ASSIGNMENT 13

QUESTION:

13. Write a Python Program to Print Current Date and Time.

ANSWER:

import datetime

current_time = datetime.datetime.now()

print("Time now at Greenwich meridian is:", current_time)

OUTPUT:

Current Date and Time: 2025-01-18 16:27:25.653993

Sample Project

Teacher's Signature: ________________

Page 15
Assignment 16

ASSIGNMENT 14

QUESTION:

14. Write a Python Program to Display Calendar.

ANSWER:

import calendar

yy = 2014 # year

mm = 11 # month

print(calendar.month(yy, mm))

OUTPUT: Sample Project


November 2014 Calendar:

November 2014

Mo Tu We Th Fr Sa Su

1 2

3 4 5 6 7 8 9

10 11 12 13 14 15 16

17 18 19 20 21 22 23

24 25 26 27 28 29 30

Teacher's Signature: ________________

Page 16
Assignment 17

ASSIGNMENT 15

QUESTION:

15. Write a Python Program to Solve Quadratic Equation.

ANSWER:

# Solve the quadratic equation ax**2 + bx + c = 0

import cmath

a = 1

b = 5

c = 6

Sample Project
d = (b**2) - (4*a*c)

sol1 = (-b-cmath.sqrt(d))/(2*a)

sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solutions are:', sol1, sol2)

OUTPUT:

The solutions are: (-3+0j), (-2+0j)

Teacher's Signature: ________________

Page 17

You might also like