0% found this document useful (0 votes)
1 views1 page

Lab Assignment 5 Operators

This document outlines a lab assignment for a Python course at Dr. B R Ambedkar National Institute of Technology, Jalandhar. It includes various programming tasks such as computing expressions, calculating Hamming distance, comparing binary numbers, removing duplicates from a list, and string comparisons. The assignment also covers tuple assignment and unpacking, requiring students to demonstrate their understanding of operators and data structures in Python.

Uploaded by

Vikas Mittal
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)
1 views1 page

Lab Assignment 5 Operators

This document outlines a lab assignment for a Python course at Dr. B R Ambedkar National Institute of Technology, Jalandhar. It includes various programming tasks such as computing expressions, calculating Hamming distance, comparing binary numbers, removing duplicates from a list, and string comparisons. The assignment also covers tuple assignment and unpacking, requiring students to demonstrate their understanding of operators and data structures in Python.

Uploaded by

Vikas Mittal
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
You are on page 1/ 1

Mk- Ckh vkj vECksndj jk"Vªh; izkS|ksfxdh laLFkku] tkya/kj

Dr. B R AMBEDKAR NATIONAL INSTITUTE OF TECHNOLOGY,


JALANDHAR
Tkh Vh jksM+ ckbZ ikl] tkya/kj&ƒ††Œƒƒ iatkc ¼Hkkjr½
G T Road ByPass, Jalandhar-144011, Punjab (India)
(Under Ministry of Human resource Development (MHRD), Government of India, New Delhi)
DEPARTMENT OF INFORMATION TECHNOLOGY
ITFC0131 Problem Solving using Python Lab

Lab Assignment-05
Operators, Precedence of Operators and Tuple assignment

Q1 Write a Python program to compute and display the results of following expressions:
result1 = 10 + 5 * 2
result2 = (10 + 5) * 2
result3 = 100 / 5 + 2 * 3
result4 = 100 / (5 + 2) * 3
result5 = 2 ** 3 * 4
result6 = 2 ** (3 * 4)
result7 = 10 > 5 and 3 < 2 or 8 == 8

Q2 Hamming distance measures the number of positions at which the corresponding bits of two
binary numbers are different. Find Hamming distance between two binary numbers. Take two
integer numbers as input from the user and use bin() function to convert in binary.

Q3 Compare two binary numbers for greater than, less than, and equality comparison using lists.

Q4 Create a dynamic list by taking duplicate inputs from the user and then remove duplicates
from the list using membership operators in and not in.

Q5 a is 20, b is 7, c is 3.0 and d is [10, 20, 30, 40]. Compute the output of the given expression:
result = ((a + b * c) // 4 - 2) ** 2 >= 10 and (a + b - c) in d.

Q6 Write a Python program that takes two strings as input from the user and compares them
using different comparison operators (==, !=, <, >, <=, >=). The program should:
1. Check if both strings are equal.
2. Check if the strings are different.
3. Compare which string is lexicographically greater.
4. Compare which string is lexicographically smaller.
5. Handle cases where the strings have different capitalizations (use .lower()).

Q7 Write a Python program that demonstrates tuple assignment. The program should:
1. Take multiple values as input from the user (comma-separated).
2. Store these values in a tuple (use split() function).
3. Use tuple unpacking to assign the values to individual variables.
4. Print each variable separately

You might also like