computer
computer
Name : Ankit
Class : 11th ‘A’
Roll no. : 23
Computer Sci. practical
file
Python Programs for Basic Operations and Patterns
1.Welcome Message
Input a welcome message and display it.
Code:
# Input a welcome message and display it.
Code:
# Input two numbers and display the larger/smaller number.
Code:
# Input three numbers and display the largest/smallest number.
# Display results
print("Perfect number:", is_perfect(num))
print("Armstrong number:", is_armstrong(num))
print("Palindrome:", is_palindrome(num))
8.Fibonacci Series
Display the terms of a Fibonacci series.
Code:
Code:
# Compute GCDandLCM import math
Code:
# Swap elements at even and odd indices in a list
Code:
# Create a dictionary of students and display those with marks above 75
students = {}
n =int(input("Enter number of students: "))
for _ in range(n):
roll_no = input("Enter roll number: ")
name =input("Enter name: ")
marks = int(input("Enter marks: "))
students[roll_no] = {"name": name, "marks": marks}
high_achievers = {k: v["name"] for k, v in students.items() if v["marks"] > 75}
print("Students with marks above 75:", high_achievers)