• C language

    To perform the sum of three numbers and print the sum.

    This Program will give basic data type of c and perform sum of this three number. #include<stdio.h> void main() { int no1,no2,no3,sum; printf("\n\tEnter First Number "); scanf("%d",&no1); printf("\n\tEnter Second Number "); scanf("%d",&no2); printf("\n\tEnter Third Number "); scanf("%d",&no3); sum=no1+no2+no3; printf("\n\t_____________________________________________"); printf("\n\n\tSum Of %d, %d And %d Is %d\n\n",no1,no2,no2,sum); }  

  • Python

    Check Whether The Number Is Prime Or Not

    Write a function that takes two numbers as input parameters and returns True or False depending on whether they are co-primes. Two numbers are said to be co-prime if they do not have any common divisor other than one. flag=0 def coprime(no1,no2): global flag mini=no1 if no1<no2 else no2 i=2 while i<mini: if no1%i==0 and no2%i==0: flag=1 break i+=1 no1=int(input("Enter First Number ")) no2=int(input("Enter Second Number ")) coprime(no1,no2) if flag==1: print("Numbers Are Not Co-Prime") else: print("Numbers Are Co-Prime") OutPut Enter First Number 25 Enter Second Number 50 Numbers Are Not Co-Prime  

  • Python

    Count Word, Line, Words Start From Vowel From File Python

    Write a python program that reads the contents of the file poem.txt and count the number of alphabets blank spaces lowercase letters and uppercase letters the number of words starting from vowel and the number of occurrences of each word in the file. alphabet=0 space=0 lower=0 upper=0 voword=0 oc=0 occur={} f=open("data.txt","r") content=f.read() vowel=['a','e','i','o','u','A','E','I',"O",'U'] print("Contet Of File") print(content) print("\nTotal Length Of File",len(content)) words=content.split(' ') #print(words) for i in range(len(content)): #print(content[i]) if (content[i]>='a' and content[i]<='z') or (content[i]>='A' and content[i]<='Z'): lower+=1 alphabet+=1 if content[i]>='A' and content[i]<='Z': upper+=1 if(content[i]==' '): space+=1 for i in range(len(words)): str=words[i] oc=0 if str[0] in vowel: voword+=1 for j…

  • Python

    Recursive Function In Python

    Write a recursive function that takes x value as an input parameter and print x-digit strictly in increasing number. [i.e. x = 6 than output 67891011]. def printdemo(x,count): if(count<=0): return else: print(x,end='') x=x+1 count=count-1 printdemo(x,count) x=int(input("Enter Number ")) printdemo(x,x) OutPut Enter Number 7 78910111213  

  • Python

    Convert Digit Into Word

    This program will convert from number to word. For this purpose we are using dictionary data type which is used with key value pairs. Here the main logic is put into function which is defined by following Syntex. def fun_name(argument): def maptoword(number): global list list=[] dic={0:'ZERO',1:'ONE',2:'TWO',3:'THREE',4:'FOUR',5:'FIVE',6:'SIX',7:'SEVEN',8:'EIGHT',9:'NINE'} temp=number while temp!=0: rem=temp%10 list.append(dic[rem]) temp=int(temp/10) i=len(list) i=i-1 while i>=0: print(list.pop(i),end=' ') i=i-1 number=int(input("Enter any number")) maptoword(number)   OutPut Enter any number123 ONE TWO THREE

  • Python

    Implement The Basic Calculator

    Here we are using basic operator and function to implement basic calculator. This program provide basic use of operator and how to work with function. con=1 while con==1: no1=int(input("Enter First Value ")) no2=int(input("Enter Second Value ")) print("Choice") print("1. Add") print("2. Subtract") print("3. Multiplication") print("4. Division") choice=int(input("Enter Choice ")) def Add(): return (no1+no2) def Sub(): return (no1-no2) def Mul(): return (no1*no2) def Div(): return (no1/no2) def perform_op(choice): if choice == 1: print(Add()) elif choice == 2: print(Sub()) elif choice == 3: print(Mul()) elif choice == 4: print(Div()) else: print("*** Invalid Choice ***") perform_op(choice) con=int(input("Do You Want To Continue "))   OutPut…

  • Python

    Implement The Gaussian Function

    The bell shaped Gaussian function, f(x)=(1/s * root(2*pi)) * exp[(-1/2) * (x-m/s)^2] is one of the most widely used functions in science and technology. The parameters m and s > 0 are prescribed real numbers. Make a program for evaluating this function for different values of s, x and m. Ask the user to input the values import math s=float(input("Enter the value of s ")) x=float(input("Enter the value of x ")) m=float(input("Enter the value of m ")) if(m<0 and s<0): print("** Invalid Input **") else: f1=1/(s*math.sqrt((2*3.14))) f2=math.exp((-1/2)*(pow(((x-m)/s),2))) f=f1*f2 print("Answer ",f) OutPut Enter the value of s 3 Enter the value…

  • Python

    Implement The Energy Equation Based On Velocity

    Solution For Below Problem A car driver, driving at velocity v0, suddenly puts on the brake. What is braking distance d needed to stop the car? One can derive, using Newton’s second law of motion or a corresponding energy equation, that d=(1/2) * (v0^2/ug) Make a program for computing d above equation, when the initial car velocity v0 and the friction coefficient μ are given on the command line. Run the program for two cases: v0 = 120 and v0 = 50 km/h, both with μ = 0.3 (μ is dimensionless). (Note: convert the velocity in m/s) import sys values=sys.argv…

  • Python

    Find The Area Of Triangle With Command Line Argument

    Hello Guys, This python program will calculate the area of equilibrium triangle. It takes the value of three sides from command line and check the third side of triangle has value greater than the sum of other two side and then calculate area for that. If the value of sides are not well then it gives error message. import sys import math def areaTriangle (values): i=1 j=2 print("File Name : ",values[0]) #print(values[1],values[2],values[3]) s=(int(values[1])+int(values[2])+int(values[3]))/2 print(s) area=math.sqrt(s * (s-int(values[1])) * (s-int(values[2])) * (s-int(values[3]))) print("Area Of Triangle Of Three Side ",area) values=sys.argv if (len(values)<=1): print("Don't Have Any Argument") else: if ((values[1]+values[2])<values[3] or (values[2]+values[3])<values[1]…