0% found this document useful (0 votes)
53 views9 pages

CS Program

The document contains code snippets for several programs: 1) A program to convert between inches/feet and centimeters for height. 2) A program to calculate simple and compound interest. 3) A program to convert between Celsius and Fahrenheit temperatures. 4) A program to order three input numbers in ascending order. 5) A program to print "tipsy", "topsy", or "tipsy topsy" for numbers between 11-40 based on divisibility by 3 or 7. 6) A program to print the letter Z using asterisks. 7) A program to check if a number is prime. 8) A program to print numbers from 1-40 in a pattern of alternating positive and negative numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views9 pages

CS Program

The document contains code snippets for several programs: 1) A program to convert between inches/feet and centimeters for height. 2) A program to calculate simple and compound interest. 3) A program to convert between Celsius and Fahrenheit temperatures. 4) A program to order three input numbers in ascending order. 5) A program to print "tipsy", "topsy", or "tipsy topsy" for numbers between 11-40 based on divisibility by 3 or 7. 6) A program to print the letter Z using asterisks. 7) A program to check if a number is prime. 8) A program to print numbers from 1-40 in a pattern of alternating positive and negative numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

# program to print height in inches and feet

h_cm=int(input("Enter height:"))

h_inch=h_cm/2.54

h_feet=h_inch/12

print("height in inches:",h_inch)

print("height in feet:",h_feet)
# program to compute simple interest and compound interest

p=int(input("enter principal amount:"))

r=int(input("enter rate of interest:"))

t=int(input("enter time period:"))

s_i=(p*r*t)/100

c_i=(p*(1+r/100)**t)-p

print("computed simple interest is ",s_i)

print("computed compound interest is",c_i)


#program to convert temperature to Celsius or Fahrenheit

temp=int(input("enter temperature:"))

print("1.temperature in celsius")

print("2.temperature in fahrenheit")

choice=int(input("enter your choice(1 or 2):"))

if choice==1:

f=9/5*temp+32

print("Temperature in fahrenheit is",f)

else:

c=5/9*(temp-32)

print("Temperature in celsius is",c)


#program that reads three number(integers) and prints them in ascending order

x=int(input("enter first number:"))

y=int(input("enter second number:"))

z=int(input("enter third number:"))

min=mid=max=None

if x<y and x<z:

if y<z:

min,mid,max=x,y,z

else:

min,mid,max=x,z,y

elif y<x and y<z:

if x<z:

min,mid,max=y,x,z

else:

min,mid,max=y,z,x

else:

if x<y:

min,mid,max=z,x,y

else:

min,mid,max=z,y,x

print("number in ascending order :",min,mid,max)


N=int(input("Enter a number(n>20):"))

for i in range (11,N):

if (i%3==0):

print("tipsy")

elif (i%7==0):

print("topsy")

elif (i%3==0 and i%7==0):

print("tipsy topsy")

print()
#program to print letter z with *

a=("*"*5)

print(a)

for i in range(1,4):

for j in range(1,5):

if(i+j==5 or j+i==5):

print("*",end=" ")

else:

print(end=" ")

print()

print(a)
#program to print a number and test if it is a prime number

num=int(input("enter a number:"))

lim=int(num/2)+1

for i in range(2,lim):

rem=num%1

if rem==0:

print(num,"is not a prime number")

break

else:

print(num,"is a prime number")


#program to print a number pattern from 1 to 40

for i in range(1,41,3):

if(i%2==0):

print(-(i),end=' ')

else:

print(i,end=' ')

You might also like