Print a box like the  below :

practical - 1 python ( start ( * )  pattern printing in python ) using simple print function.

*******************

 *******************

 *******************

 *******************


code : 

print("*"*19)
print("*"*19)
print("*"*19)
print("*"*19)  


******************* 

*                                  *

*                                  *

 *******************

code : 

print("*"*19)
print("*"," "*15,"*")
print("*"," "*15,"*")
print("*"*19)


*
  ** 
  ***
   ****

code :

print("*\n*\n***")
 Write a program that computes and prints the result of 512 − 282 47 · 48 + 5 . It is roughly 1017. 

t=(512-282)/(47*48+5)
print(t)
output : 9.844144903117101

Ask the user to enter a number. Print out the square of the number, but use the sep optional argument to print it out in a full sentence that ends in a period. Sample output is shown below :  

enter the number : 5
the squre root of  5 is 25

num=eval(input('enter the number : '))

square = num*num
print("the squre root of ",num,'is',square,sep=' ')
print("\n")

output : 

enter the number : 5
the squre root of  5 is 25

  Ask the user to enter a number x. Use the sep optional argument to print out x, 2x, 3x, 4x, and 5x, each separated by three dashes, like below :

Enter a number: 7 

7---14---21---28---35

code :

x =eval(input('enter the number : 7'))
print(x,2*x,3*x,4*x,5*x,sep="--")

output :

Enter a number: 7 

7---14---21---28---35

Write a program that asks the user for a weight in kilograms and converts it to pounds. There are 2.2 pounds in a kilogram

code :

weigth = eval(input('enter yor weight :'))
pound = weigth* 2.2046
print("your weight is",weigth,"kilograms","its mean your weight is",pound,
"pound",sep=" ")

output :

enter yor weight :50
your weight is 50 kilograms its mean your weight is 110.23 pound

write a program that asks the user to enter three numbers (use three separate input state�ments). Create variables called total and average that hold the sum and average of the
three numbers and print out the values of total and average. 

code :

a = eval(input('enter first number : '))
b = eval(input('\nenter secound number : '))
c = eval(input('\nenter third number :'))
total = a + b + c
average = (a + b + c)/2
print("\nsum of",a,b,c,"is",total,sep=" ")
print("\naverage of",a,b,c,"is",average,sep=" ")


output : 

enter first number : 20 
enter secound number : 30
 enter third number :40 
sum of 20 30 40 is 90
average of 20 30 40 is 45.0
 A lot of cell phones have tip calculators. Write one. Ask the user for the price of the meal and
the percent tip they want to leave. Then print both the tip amount and the total bill with the
tip included. 

code :

#makae a tip calculators
price = int(input('Enter the price of meal : '))
tip = int(input('Enter the percent of tip you wana leave : '))
bill_of_meal = price * (tip/100)
total_bill = price + bill_of_meal
print('Bill of meal : ', price,'\ntip : ',tip,'\nTotal bill : ' ,
total_bill)


output :

Enter the price of meal :15
Enter the percent of tip you wana leave=10
 bill_of_meal = 15
tip= 169
Total bill= 60.50


practical - 1  

A_Practical_Introduction_to_Python_Programming_Heinold

check my blog for all answers 






keywords : 
python dictionary
for loop python
online python compiler
online python
python compiler
python download
python programming
python for loop