0% found this document useful (0 votes)
4 views29 pages

Python Programming Basics and Examples

The document contains a series of programming tasks in Python, each requiring the implementation of specific functionalities such as arithmetic operations, string manipulations, and control flow statements. It includes examples of using input functions, loops, and built-in methods for lists and strings. Additionally, it covers mathematical calculations, condition checks, and printing outputs in various formats.

Uploaded by

kunshlock
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)
4 views29 pages

Python Programming Basics and Examples

The document contains a series of programming tasks in Python, each requiring the implementation of specific functionalities such as arithmetic operations, string manipulations, and control flow statements. It includes examples of using input functions, loops, and built-in methods for lists and strings. Additionally, it covers mathematical calculations, condition checks, and printing outputs in various formats.

Uploaded by

kunshlock
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

1. Write the program to subtract two no.s using input func.

OUTPUT:
2. Write the Python Program multiplication of two numbers using input function.

OUTPUT:
3. Write the Python Program to demonstrate the use of the break statement in a
loop.

OUTPUT:
4. Write the Python Program to demonstrate the use of the

continue statement in a loop.

OUTPUT:
5. Write the Python Program to print multi line strings.

OUTPUT:
6. Write the Python Program to access different elements of a string.

OUTPUT:
7. Write the Python Program to join two or more strings using string concatenation
operator.

OUTPUT:
8. Write the Python Program to repeat a string using string replication operator.

OUTPUT:
9. Write the Python Program to use various string Python built-in functions.

# Define a string

text = " Hello, Python Programming! "

print("Original String:", repr(text))

# 1. Convert to lowercase

print("Lowercase:", [Link]())

# 2. Convert to uppercase

print("Uppercase:", [Link]())

# 3. Remove leading/trailing spaces

print("Stripped:", [Link]())

# 4. Replace a word

print("Replace 'Python' with 'Java':", [Link]("Python", "Java"))


# 5. Split string into list

print("Split by spaces:", [Link]())

# 6. Join list of strings

words = ["Python", "is", "fun"]

print("Join words with '-':", "-".join(words))

# 7. Check start and end

print("Starts with ' Hello':", [Link](" Hello"))

print("Ends with 'ing! ':", [Link]("ing! "))

# 8. Find substring

print("Index of 'Python':", [Link]("Python"))

# 9. Count occurrences

print("Count of 'm':", [Link]("m"))


# 10. Check string properties

print("Is alphabetic?:", "Hello".isalpha())

print("Is digit?:", "12345".isdigit())

print("Is alphanumeric?:", "Hello123".isalnum())

OUTPUT:
10. Write the Python Program to perform any three arithmetic operators.

OUTPUT:
11. Write the Python Program to perform any three assignment operators.

OUTPUT:
12. Write the Python Program to perform all the logical operators.

OUTPUT:
13. Write the Python Program to perform any three relational operators.

OUTPUT:
14. Write the Python Program to calculate the average marks of three subjects.

OUTPUT:
[Link] the Python Program to find out if the student is selected for the college or
not

OUTPUT:
16. Write the Python Program to check if the given number is lucky or not. If the
given number is greater than zero and is even, then print “Lucky Number” else
print”Not a lucky number”.

OUTPUT:
17. Write the Python Program to check whether a given number is two-digit number,
three-digit number or four-digit number.

OUTPUT:
18. Write the Python Program to print the different types of lists.

OUTPUT:
19. Write the Python Program to print the nested list.

OUTPUT:
20. Write the Python Program to use the Python list bulit-in

methods

OUTPUT:
21. Write the Python Program using append() in the list.

OUTPUT:
22. Write the Python Program, a student has to travel a distance of 450km by car
at a certain average speed. Write the Python code to find the total time taken to
cover the distance.

OUTPUT:
[Link] the Python Program to print your name nine times using FOR Loop with
range() function.

OUTPUT:
24. Write the Python Program to check whether a given number is negative or
positive. If the number is positive then print”Positive Number”. If the number is
negative, then print ”Negative Number”.

OUTPUT:
25. Write the Python Program to calculate the Area of Circle.

OUTPUT:

26. Write the Python Program to calculate the Area of Rectangle.

OUTPUT:
27. Write the Python Program to print all the days of a week.

OUTPUT:
28. Write the Python Program to print multiplication table of an input number.

OUTPUT:

You might also like