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:
*
.Program-6:
Program-7:
Program-8:
Program-9:
Program-10:
1000000
→ 1,000,000
).Program-11:
*
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)
.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 →
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
Post a Comment