0% found this document useful (0 votes)
3 views2 pages

Python Operators and Strings Exercises

The document outlines a series of programming assignments focused on operators and strings in Python. It includes tasks such as performing arithmetic operations, using modulus and bitwise operators, manipulating strings, and checking for palindromes. Each section provides specific instructions for coding exercises to enhance understanding of Python fundamentals.

Uploaded by

vrshchkrbrt
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)
3 views2 pages

Python Operators and Strings Exercises

The document outlines a series of programming assignments focused on operators and strings in Python. It includes tasks such as performing arithmetic operations, using modulus and bitwise operators, manipulating strings, and checking for palindromes. Each section provides specific instructions for coding exercises to enhance understanding of Python fundamentals.

Uploaded by

vrshchkrbrt
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

Assignment

🔹 Operators in Python
1. Write a Python program to take two numbers as input and print their:
- Sum
- Difference
- Product
- Quotient

2. Given a = 15 and b = 4, find:


-a%b
- a // b
- a ** b

3. Take an integer input and check whether it is even or odd using the modulus (%)
operator.

4. Write a program to swap two numbers using only arithmetic operators (no third
variable).

5. Given x = 10, y = 20, evaluate and print the result of:


- x > y and x < y
- x != y or x == 10
- not(x > y)

6. If p = 5, q = 10, use bitwise operators to find:


-p&q
-p|q
-p^q
- ~p
- p << 2
- q >> 1

🔹 Strings in Python
1. Take a string input from the user and print its length.

2. Write a program to:


- Convert a string to uppercase.
- Convert the same string to lowercase.
3. Given s = 'Python Programming', print:
- The first 6 characters
- The last 5 characters
- Characters from index 3 to 8

4. Check whether the word 'Python' is present in the string 'I love Python programming'.

5. Reverse a string using slicing.

6. Count how many times the letter 'a' appears in the string 'bananas'.

7. Take two strings as input and concatenate them with a space in between.

8. Write a program to check if a given string is a palindrome (same forward and backward).

9. Replace all spaces in 'Hello World, Python is fun' with '-'.

10. Split the string 'apple,banana,grape,mango' into a list and print each fruit separately.

You might also like