[go: up one dir, main page]

0% found this document useful (0 votes)
5 views3 pages

Python Basic Assignement Day 1 August Batch 2025

pyhton aissngent for baisc day 1

Uploaded by

backup83404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Python Basic Assignement Day 1 August Batch 2025

pyhton aissngent for baisc day 1

Uploaded by

backup83404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Pramilix International Private Limited

www.pramilix.in
admin@pramilix
.in

2-A/3 S/F,Asaf Ali Road, Turkman Gate Darya Ganj New Delhi

Python Coding Questions (Assignment)

29-07-2025

1. Write a program to check whether a number is odd or even.


Input: 7
Output: Odd
2. Write a function that returns the maximum of two numbers.
Input: 45 78
Output: 78
3. Write a program to check whether a number is prime or not.
Input: 13
Output: Prime
4. Write a function that returns the reverse of a string.
Input: "python"
Output: "nohtyp"
5. Count the number of vowels in a given string.
Input: "Hello World"
Output: 3
6. Write a program to calculate the factorial of a number.
Input: 5
Output: 120
7. Write a function that checks if a string is a palindrome.
Input: "madam"
Output: Yes, it is a palindrome.
8. Write a program to print the multiplication table of a number using a loop.
Input: 4
Output:

4 x 1 = 4
4 x 2 = 8
...
4 x 10 = 40

Head Office : 2-A/3 S/F Front Side,Asaf Ali Road, Turkman Gate Darya Ganj New Delhi Central Delhi
DL 110002
www.pramilix admin@pramilix
.in .in
9. Write a program to print all even numbers between 1 to 20.
Output: 2 4 6 8 10 12 14 16 18 20
10. Write a program that uses try-except to handle division by zero.
Input: 10 / 0
Output: Division by zero is not allowed.
11. Write a function with optional parameter greeting="Hello" that prints greeting with
name.
Input: ("Kundan")
Output: Hello, Kundan
12. Write a program to count digits of a number.
Input: 3489
Output: 4
13. Write a program to check whether a number is positive, negative or zero.
Input: -3
Output: Negative
14. Write a program to print all characters of a string one by one using a loop.
Input: "code"
Output:

c
o
d
e

15. Write a program to print the sum of all numbers from 1 to N.


Input: 10
Output: 55
16. Write a function that takes a list of numbers and returns a new list with only even
numbers.
Input: [1, 2, 3, 4, 5, 6]
Output: [2, 4, 6]
17. Create a program that counts the frequency of each character in a string using a
dictionary.
Input: "hello"
Output: {'h': 1, 'e': 1, 'l': 2, 'o': 1}
18. Write a function to find the second largest number in a list.
Input: [4, 9, 1, 12, 7]
Output: 9
19. Write a program that reverses a number using a loop.
Input: 1234
Output: 4321
20. Write a program that prints all prime numbers between 1 and 50.
Output: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
21. Write a program that asks for a number and prints whether it's divisible by 3, 5, or
both.
Input: 15
Output: Divisible by both 3 and 5
22. Write a function that accepts a string and returns the number of words.
Input: "Python is awesome"
Output: 3
23. Write a program that takes a list of numbers and calculates both sum and average.
Input: [10, 20, 30, 40, 50]
Output:

Head Office : 2-A/3 S/F Front Side,Asaf Ali Road, Turkman Gate Darya Ganj New Delhi Central Delhi
DL 110002
www.pramilix admin@pramilix
.in .in
Sum = 150
Average = 30.0

Head Office : 2-A/3 S/F Front Side,Asaf Ali Road, Turkman Gate Darya Ganj New Delhi Central Delhi
DL 110002
www.pramilix admin@pramilix
.in .in

You might also like