JNTU Python Lab Questions with Solutions

 

Program-1:

Convert weight in kilograms to pounds (1 kg = 2.2 lbs).


Program-2:

Take three numbers as input, find their sum and average.




Program-3:
Use a for loop to print numbers 8, 11, 14, ..., 86, 89.




Program-4:

Ask the user for their name and repeat it N times.


Program-5:

Print a triangle pattern using *.


Program-6:

Generate a random number (1-10), ask the user to guess it.



Program-7:

Check if two numbers are within 0.001 of each other.


Program-8:

Ask for a word and check if it contains vowels.



Program-9:

Input two strings of the same length and alternate their characters.


Program-10:

Format a large number with comma separators (e.g., 10000001,000,000).



Program-11:

Convert algebraic expressions by inserting * where needed.


Program-12:

Generate 20 random numbers (1-100) and do the follwing:
  • print the list.
  • Find the average, max, min, second largest, second smallest.
  • Count the even numbers.


Program-13:

Find all factors of a number.



Program-14:

Generate 100 random 0s and 1s, find the longest run of 0s.


Program-15:

Remove duplicates from a list.



Program-16:

Convert feet to inches, yards, miles, meters, etc., based on user input.



Program-17:

Function sum_digits(num) to return the sum of digits.



Program-18:

Function first_diff(s1, s2) to find the first different character in two strings.



Program-19:

Function number_of_factors(n) to return number of factors of n.



Program-20:

Function is_sorted(lst) to check if a list is sorted.


Program-21:

Function root(x, n=2) to compute x^(1/n).


Program-22:

Function primes(n=100) to return first N prime numbers.



Program-23:

Function merge(l1, l2) to merge two sorted lists.

 
Program-24:

Find smaller words from letters of a given word.


Program-25:

Read a file of emails, print them separated by semicolons(;).


Program-26:

Convert temperatures in temps.txt from Celsius to Fahrenheit and save in ftemps.txt.


Program-27:

Class Product with:Fields: name, amount, price
get_price(n): Applies discounts (10% for 10-99 items, 20% for 100+ items).
make_purchase(n): Reduces stock count.


Program-28:

Class Time to convert:Seconds → minutes:seconds
Seconds → hours:minutes:seconds


Program-29:

Class Converter to convert length units (inches, feet, yards, km, etc.).



Program-30:

Implement pow(x, n) using a class.



Program-31:

Reverse a string word-by-word using a class.


Program-32:

Open a file dialog to display the contents in a textbox (Tkinter).


Program-33:

Demonstrate try/except/else error handling.


Program-34:

Demonstrate try/finally and with/as for file handling.




Comments