“””
use python while loop to print the following output
*****
****
***
**
*
“””
x = 5
while x != 0:
txt = “”
y = 1
while y <= x:
txt += “*”
y = y + 1
print(txt)
x = x – 1
…………………………………………………………………………………
“””
write a program to print even numbers between 20 and 50
“””
x = 20
while x <= 50:
if x % 2 == 0:
print(x)
x = x + 1
………………………………………………………………………………..
“””
write a program to print odd numbers between 50 and 100
“””
x = 50
while x <= 100:
if x % 2 != 0:
print(x)
x = x + 1
……………………………………………..
“””
write a program to print student grade (fail, pass, good, v.good, excellent) based on his degree (int number)
“””
degree = 67
if degree < 50:
print(“fail”)
elif degree >=50 and degree < 65:
print(“pass”)
elif degree >= 65 and degree < 75:
print(“good”)
elif degree >= 75 and degree < 85:
print(“very good”)
elif degree >= 85:
print(“excellent”)
……………………………………………………….
“””
write a program to ask the use to input the radius of the circle then
calculate the area of the circle and print it
area = pi * r^2
“””
from math import pi
# radius of the circle (any value)
r = float( input(“Please enter the radius: “) )
area = pi * r**2
print(“area is ” + str(area))
………………………………………………..
“””
write a program to reverse a string using python loops
“””
txt = “hello, world”
rev_txt = “”
# get length of text
i = len(txt) – 1
while i >= 0:
rev_txt += txt[i]
i = i – 1
print(rev_txt)
……………………………………………
“””
write a program to create a list of numbers
and fill with numbers between 1 – 10
then increase all numbers in the list by 5 using while loop
then print the updated list
“””
nums = []
# fill with numbers between 1 – 10
i = 1
while i <= 10:
nums.append(i)
i += 1
# add 5 to each number
nums_updated = []
for x in nums:
new_val = x + 5
nums_updated.append(new_val)
# print
print(nums_updated)
………………………………………..
“””
write a program to ask the user to fill list with item prices
then print the total price
the ask the user about the discount (ex. 30% for all prices not on total price)
then apply the discount and print the final prices and the final total price
“””
item_count = int( input(“How many items: “) )
prices = []
i = 0
while i < item_count:
item_price = float( input(“enter price of item #” + str(i + 1) + “: “))
prices.append(item_price)
i += 1
print(prices)
total_price = sum(prices)
print( “totalt price = ” + str(total_price) )
discount = float( input(“enter discount : “) )
prices_updated = []
i = 0
while i < item_count:
new_price = prices[i] – prices[i] * discount / 100
prices_updated.append(new_price)
i += 1
print(“updated prices:”)
print(prices_updated)
total_price_updated = sum(prices_updated)
print(“the new total price is ” + str(total_price_updated))
……………………………………………………………………….
“””
use python loop to calculate the sum of the following list
[456, 85, 36, 978, 22, 22.6, 13.8, 20]
“””
my_list = [456, 85, 36, 35, 22, 22.6, 13.88, 20]
sum = 0
i = 0
while i < len(my_list):
sum += my_list[i]
i += 1
print(“sum is ” + str(sum))
…………………………………………………………
“””
write a python program to find the max number on the following list:
[456, 85, 36, 978, 22, 22.6, 13.8, 20]
“””
my_list = [456, 85, 36, 978, 22, 22.6, 13.8, 20]
# set max as the first item in the list
max_num = my_list[0]
i = 0
while i < len(my_list):
if my_list[i] > max_num:
max_num = my_list[i]
i += 1
print(“max number is ” + str(max_num))
…………………………………………………………..
Order Cheap Propecia zoloft require prescription in canada Cialis Tratamiento Impotencia Comprare Cialis Originale