Computer Science, asked by RubySinha1, 1 year ago

How can we do this?Please answer step wise and how we have to write the program.

Attachments:

Answers

Answered by garywalter1221
0

first answer

logic of the program

for num in range(1,100):

   if num%2==0:

       print num

   num=num+1


2.Logic of second program

n=int(input("Enter the number to print the tables for:"))

for i in range(1,11):

   print(n,"x",i,"=",n*i)


3.logic of 3 program

for Number in range (1, 101):

   count = 0

   for i in range(2, (Number//2 + 1)):

       if(Number % i == 0):

           count = count + 1

           break

   if (count == 0 and Number != 1):

       print(" %d" %Number, end = '  ')

4.logic

num = int(input("Enter the value of n: "))

hold = num

sum = 0

if num <= 0:  

  print("Enter a whole positive number!")  

else:  

  while num > 0:

       sum = sum + num

       num = num - 1;

   # displaying output

   print("Sum of first", hold, "natural numbers is: ", sum)


5.logic

num=int(raw_input("Enter a number"))

n=1

while num>0:

n=n*num

num=num-1

print "Factorial of the given number is ",n


6.logic

PI = 3.14

r = float(input('Enter the radius of the circle :'))

area = PI * r * r

print("Area of the circle is : %.2f" %area)


7.logic

a=int(input("Enter the first number:"))

b=int(input("Enter the second number:"))

if(a>b):

   min1=a

else:

   min1=b

while(1):

   if(min1%a==0 and min1%b==0):

       print("LCM is:",min1)

       break

   min1=min1+1


8.logic

princ_amount = float(input(" Please Enter the Principal Amount : "))

rate_of_int = float(input(" Please Enter the Rate Of Interest   : "))

time_period = float(input(" Please Enter Time period in Years   : "))

simple_interest = (princ_amount * rate_of_int * time_period) / 100

print("\nSimple Interest for Principal Amount {0} = {1}".format(princ_amount, simple_interest))


hope it will help u


FlashMello613: Your first program is wrong
FlashMello613: the last no. would then be 98
FlashMello613: coz the stop no. should be 1 greater than what we want
Answered by FlashMello613
0
#Program - 1
for x in range(0, 101, 2):
print(x, end=", ")

#Program - 2
n=float(input("Enter the No. to get it's Multiplication Table :- '))
for i in range(0, 11, 1):
a=n*i
print(a, end=", ")

#Program - 3
for a in range(2, 98, 1):
for x in range(2, 98, a):
if x%a==1 or x%a==2 or x%a==3 or x%a==5 or x%a==7:
print(x)

#Program - 4
n=int(input("Enter the no. of terms of Natural No. to be summed up to :- "))
a=(n*(n+1))/2
print("The sum till that no. is =", a)

#Program - 5
n=int(input("Enter a no. to find it's Factorial :- "))
for i in range(n-1, 1, -1):
n*=i
print(n)

#Program - 6
a=int(input("Enter the First no. :- "))
b=int(input("Enter the Second no. :- "))
for n in range(a, b, a+b)
LCM=(a*b)/n
print(LCM)

#Program - 7
import math
R=float(input("Enter the Radius (R) of the Circle in metres (m) :- "))
A=(math.pi)*(R**2)
print("Area of that Circle with Radius,"R,", in square metres (m^2) is =",A)

#Program - 8
n=int(input("Enter a Two-Digit No. :- "))
a=n//10
n%10
b=n//10
print(a,b, end="")

#Program - 9
P=float(input("Enter the Principal Amount (P) in Rupees (Rs.) :- "))
R=float(input("Enter the Rate of Interest (R) per annum (p.a.) :- "))
T=float(input("Enter the Time-Period (T) in years (y) :- "))
SI=(P*R*T)/100
print("The Simple Interest is =",SI)
Similar questions