The document contains a list of Python programming exercises designed for HPSC, covering a variety of topics such as mathematical calculations, string manipulations, data structures, and algorithms. Each exercise includes specific tasks like calculating areas, swapping numbers, checking for palindromes, and generating sequences. The exercises aim to enhance programming skills and understanding of Python fundamentals.
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 ratings0% found this document useful (0 votes)
15 views5 pages
Python Programs For HPSC
The document contains a list of Python programming exercises designed for HPSC, covering a variety of topics such as mathematical calculations, string manipulations, data structures, and algorithms. Each exercise includes specific tasks like calculating areas, swapping numbers, checking for palindromes, and generating sequences. The exercises aim to enhance programming skills and understanding of Python fundamentals.
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/ 5
Python Programs for HPSC
1. Write a python program to find the square of a number.
2. Write a python program to calculate area and perimeter of a rectangle 3. Write a program to swap two numbers i. using a third variable ii. Without using a third variable 4. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user 5. Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old. 6. Write a program in python to show accepting data as input from the console and displaying output 7. Write a program to find out the absolute value of a number n 8. Write a program to sort 3 numbers 9. Write a program to find out divisibility of a number n by another number m, where m and n are integers input by the user 10.Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer input by the user 11.Write a program that checks whether an input number is a palindrome or not. 12.Write a program to print the following patterns
13.Write a program to find the sum of 1+ 1/8 + 1/27......1/n3, where n is the
number input by the user. (Summation of a series) 14.Write a program to calculate the factorial of a given number. 15.Input a string having some digits. Write a program to return the sum of digits present in this string 16.Write a program to input line(s) of text from the user until enter is pressed. Count the total number of characters in the text (including white spaces),total number of alphabets, total number of digits, total number of special symbols and total number of words in the given text. (Assume that each word is separated by one space) 17.Write a program that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence. 18.Write a program for finding the maximum, minimum and mean of numeric values stored in a list 19.Write a program to implement linear search on list of numbers 20.Write a program for counting the frequency of elements in a list 21.Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements occurring multiple times in the list should appear only once 22.Write a program for finding the maximum, minimum and mean of numeric values stored in a tuple 23.Write a program to implement linear search on tuple of numbers 24.Write a program for counting the frequency of elements in a tuple 25.Write a program to count the number of times a character appears in a given string using a dictionary 26.Write a program to create a dictionary with names of employees, their salary and access them 27.Write a Python program to find the highest 2 values in a dictionary. 28.Write a program to read email IDs of n number of students and store them in a tuple. Create two new tuples, one to store only the usernames from the email IDs and second to store domain names from the email IDs. Print all three tuples at the end of the program. Use the function split() 29.Write a Python program to create a dictionary from a string. Note: Track the count of the letters from the string. Sample string : 'w3resource' Expected output : {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1} 30.Write a python program to check whether a entered number is prime or not 31.Write a python program to remove duplicates from a list in python. 10 Marks Example: sample_list = [11, 15, 13, 16, 13, 15, 16, 11] output_list = [11,15,13,16] 32.Write a Python program to print even length words in a string. For example: Input: I am the best student of CS Academy in Haryana Output: am best of CS in 33.Write 2 different python programs to reverse a string. 34.Write a Python code to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are the square of the keys. 35.Write a python program to find out the sum and average of numbers in a list 36.Write a python program to print the following pattern of numbers. 7 Marks 1 12 123 1234 12345 37.Write a code in python to print the Fibanocci sequence upto n terms, n is entered by the user. To be specific. Complete the following program 10 Marks