You are on page 1of 16

NAME – ROHIT YADAV

ROLLNO. – 2023UIT3122
BRANCH – IT
SECTION – 2
COURSE – BTECH.
SUBJECT – COMPUTER
PROGRAMMING
SUBJECT CODE – FCCS0102
AIM:-

WRITE A PYTHON PROGRAM TO PRINT “HELLO, WORLD”

CODE :-

print(“Hello , World”)

RESULT:-
Exp: Write a python program to check if a number is even or odd
INPUT:
num=int(input("Enter number: "))
if (num%2) == 0:
print( num,"is even number")
else: print(num,"is odd number")

OUTPUT:
AIM : create and manipulate numpy array, perform basic operations and indexing on array

CODE

import numpy as np

array =np.array([1,2,3,4,5,6,7,8,9,10])

#addition

addition=array +1

#subtraction

subtraction=array-1

#multiplication

multiplication=array*5

#division

division=array/3

#taking square

square=array**2

#square root

sq_root=array**0.5

first_element=array[0]

range_of_element=array[1:9]

print("original array is :",array)

print("adition of 1 in array",addition)

print("subtraction of 1 from array",subtraction)

print("multiplication of 5 with array",multiplication)

print("division of array from 3",division)

print("square of array",square)

print("square root of array",sq_root)

OUTPUT
AIM :-

CODE:-

if num % 2 == 0:

print(num, "is even.")

else:

print(num, "is odd.")


AIM : Create a module that contains function for mathematical
operations
CODE:
def add(x, y):
return x + y

def subtract(x, y):


return x - y

def multiply(x, y):


return x * y

def divide(x, y):


if y == 0:
return "Cannot divide by zero"
return x / y

a=divide(3,4)
print(a)

OUTPUT:
AIM:-

WRITE A PYTHON PROGRAM TO PRINT FIBONACCI SERIES USING A FOR LOOP

CODE :-
num_terms = int(input("Enter the number of terms for Fibonacci series: "))

first_term, second_term = 0, 1

print("Fibonacci Series:")

print(first_term)

print(second_term)

for i in range(2, num_terms):

next_term = first_term + second_term

print(next_term)

first_term, second_term = second_term, next_term

RESULT:-
AIM:- Import and use external packages (eg. MATH ,RANDOM)
CODE :-
import math
angle_rad = math.radians(95)
sin_val = math.sin(angle_rad)
cos_val = math.cos(angle_rad)
print(f"Sin(45 degrees) is approximately: {sin_val}")
print(f"Cos(45 degrees) is approximately: {cos_val}")

Imoprt random
fruits = ["Apple", "Banana", "Cherry", "Orange"]
random_fruit = random.choice(fruits)
print(f"Random Fruit: {random_fruit}")

RESULT:-
AIM : use dictionaries to store and retrive
student grades
CODE:
student_grades = {}

def add_grade(student_name, grade):

student_grades[student_name] = grade

def get_grade(student_name):

return student_grades.get(student_name, "Student not found")

add_grade("Aman", 85)

add_grade("Rajit", 92)

add_grade("Mridul", 78)

print("Aman's grade:", get_grade("Aman"))

print("Rajit's grade:", get_grade("Rajit"))

print("Mridul's grade:", get_grade("Mridul"))


print("Harsh's grade:", get_grade("Harsh"))

OUTPUT:

2
AIM:-

WRITE A PYTHON PROGRAM TO CHECK A GIVEN STRING IS PALINDROMIC

CODE :- # Function to check if a string is a palindrome

def is_palindrome(s):

cleaned_string = s.replace(" ", "").lower()

return cleaned_string == cleaned_string[::-1]

# Get user inpuinput_string = input("Enter a string: ")

if is_palindrome(input_string):

print("The string is a palindrome.")

else:

print("The string is not a palindrome.")

RESULT:-
AIM : use lambda function , map and filyer to perform operation on a
list
Code :
words = ["Apple", "Banana", "Avocado", "Cherry", "Apricot"]
filtered_words = list(filter(lambda x: x.startswith("A"), words))
print(filtered_words)

OUTPUT:

You might also like