Python Programs With Output[1]
Python Programs With Output[1]
Code:
2. FizzBuzz:
Print numbers from 1 to 50.
For multiples of 3, print “Fizz”
For multiples of 5, print “Buzz”
For multiples of both 3 and 5, print “FizzBuzz
Code:
3. Inverted Triangle Pattern:
Input: n = 5
Code:
4. Number Triangle
Input: n = 5
Code:
5.Print numbers from 1 to 20 but skip number 13
Code:
6. Write a python program to keep taking integer ,inputs from the user
until the user enters 'q' (for quit)
After the user quits:
Calculate the average of the ntered numbers
Calculate the product of the entered numbers
then print both values
(You can usa a while loop)
Code:
7. You are given a number, stored in a variable with the name num.For all
numbers in the range of [1, num], including num, print the output
according to the following conditions
If the current number, is divisible by both 2 and 3. i.e. num % 2 and num
% 3 == 0 print “Both” (without quotes)
• If the number is only divisible by 2. print 'Two', without quotes
• Else, if the number is not divisible by both 2 and 3. Print ‘None’ without quotes.
Code:
8. Pizza Order Program:Small pizza : Rs.100 Medium pizza : Rs.200 Large
pizza : Rs.300
Based on the user’s order (which you will take using input statements) .
Write the program to calculate the total bill.
Code:
9. Smart Home Thermostat
In a smart home system, users set a preferred temperature. Depending on
the current room temperature, the system should decide whether to
heat, cool, or take no action. Write a function
adjust_temperature(current_temp, preferred_temp) that returns one of
the following strings: "Turn on heating", "Turn on cooling", or "No action
needed".
Code:
10. Ask user to enter age, sex ( M or F ), marital status ( Y or N ) and then
using following rules print their place of service.
Code: