Posts

Showing posts from October, 2017

CODE ONLINE PLEASE VISIT ANY OF THE FOLLOWING....

TO FIND EVEN NUMBERS UP TO N

Image
TO FIND EVEN NUMBERS UP TO N a=int(input("Hello Enter Your Input:")) i=0 for i in range(i,a+1):       r=(i)%2       if (r==0):           print(i) OUTPUT --------------------------------------------------------------------------------------------------------------------------

ENTERED NUMBER IS PRIME OR NOT

Image
ENTERED NUMBER IS PRIME OR NOT n=int(input("enter a number:")) if n<0:     print "enter a valid input" elif n<2:     print "neither prime nor composite" else:     for i in range(2,n/2):         if(n%i)==0:             print n,"is not a prime number"             break     else:         print n,"is a prime number"              OUTPUT --------------------------------------------------------------------------------------------------------------------------

TO CHECK STRING IS PALINDROME OR NOT.

Image
     TO CHECK STRING IS PALINDROME OR NOT s=raw_input("enter a string:") b=reversed(s) if list(s)==list(b):     print"entered string is palindrome" else:     print "entered string is not palindrome" OUTPUT --------------------------------------------------------------------------------------------------------------------------

LARGEST NUMBER AMONG 3 NUMBERS.

Image
LARGEST NUMBER AMONG 3 NUMBERS.--USING PYTHON              a=float(input("Enter Your First Input:"))  b=float(input("Enter Your Second Input:"))  c=float(input("Enter Your Third Input:")) if (a>b and a>c):     print (a,"Is Largest") elif (b>a and b>c):     print (b,"Is Largest") else:     print (c,"Is Largest")     

FIND NUMBER OF VOWELS IN A STRING

Image
FIND NUMBER OF VOWELS IN A STRING c=raw_input("Enter A String:") b=c.lower() x=0 for letter in b:     if letter in "aeiou":         x+=1 print "Total Number Of Vowels = " + str(x) print "Number Of Vowels In Each" d,e,f,g,h=0,0,0,0,0 for letter in b:     if letter in "a":         d+=1 print "a=" +str(d) for letter in b:     if letter in "e":         e+=1 print "e=" +str(e) for letter in b:     if letter in "i":         f+=1 print "i=" +str(f) for letter in b:     if letter in "o":         g+=1 print "o=" +str(g) for letter in b:     if letter in "u":         h+=1 print "u=" +str(h) OUTPUT               

CALCULATOR

Image
CALCULATOR This post shows a simple calculator using python(2.7).It uses function for doing operations. an example:for addition -   def addition(x,y): "This Function For Addition" return x+y.                                               This function reads 2 values from the main and returns the sum to 'c'..     def addition(x,y): "This Function For Addition" return x+y def substraction(x,y): "This Function For Substraction"  return(x-y) def multiplication(x,y): "This Function For Multiplication" return(x*y) def division(x,y): "This Function For Division" return(x/y) print "Select A Operation" print "1-> Addition" print "2-> Substraction" print "3-> Multiplication" print "4-> Division" choice=int(input("Enter A Choice(1,2,3,4):")) #Main Program if choice>4: print "Sorry.....

HELLO WORLD

HELLO WORLD // In this post i explain how can display a sentence or word in a python program. Normally in python it is easy to do this.Simply writing this piece  of code ( an example:  print " Hello world "  )to a python compiler and run it...              write your message by  print"YOUR MESSAGE".

INTRODUCTION TO PYTHON

Image
INTRODUCTION TO PYTHON               Welcome!   Python is a widely used high-level programming language for general-purpose programming, created by Guido van Rossum and first released in 1991. An interpreted language, Python has a design philosophy that emphasizes code readability (notably using whitespace indentation to delimit code blocks rather than curly brackets or keywords), and a syntax that allows programmers to express concepts in fewer lines of code than might be used in languages such as C++ or Java. The language provides constructs intended to enable writing clear programs on both a small and large scale. Python features a dynamic type system and automatic memory management and supports multiple programming paradigms, including object-oriented, imperative, functional programming, and procedural styles. It has a large and comprehensive standard library.[26] Python interpreters are available for many operating systems, allowing P...

SIMPLE CALCULATOR USING C

Image
#include<stdio.h> void main() { int a,b,c,e; char d;  do   {   printf("Enter your choice:\n");   printf("MENU\n");   printf("1:Add\n2:sub\n3:mult\n4:div\n");   scanf("%d",&a);    switch(a)    {     case 1:     printf("Enter 2 numbers:");     scanf("%d %d",&b,&c);     e=b+c;     printf("the sum between %d and%d is %d",b,c,e);     break;     case 2:     printf("Enter 2 numbers:");     scanf("%d %d",&b,&c);     e=b-c;     printf("the diffrence between %d and%d is %d",b,c,e);     break;     case 3:     printf("Enter 2 numbers:");     scanf("%d %d",&b,&c);     e=b*c;     printf("the multiplication between %d and%d is %d",b,c,e);     break; ...

HCF and LCM USING C

Image
//TESTED IN TERMINAL // C program to find hcf and lcm: The code below finds highest common factor and least common multiple of two integers. HCF is also known as greatest common divisor(GCD) or greatest common factor(gcf) . #include<stdio.h> void main() {  int a,b,c,d,e;   printf("Enter 2 numbers:\n");   scanf("%d %d",&a,&b);   c=a;d=b;    while(a!=b)     {     if(a>b)       a=a-b;     else       b=b-a;     } printf("hcf of %d and %d is %d\n",c,d,a); {   e=((c*d)/a); printf("lcm of %d and %d is %d\n",c,d,e); } }

SINGLY LINKED LIST USING C

Image
#include<stdio.h> #include<stdlib.h> struct node      {       int data;       struct node *next;      }; void display(struct node *temp)      {        printf("\nElements in the list are===");        while(temp!=NULL)          {            printf("\n%d",temp->data);            temp=temp->next;           }      }  struct node * insert(struct node *start)     {       struct node *temp,*prev;      int pos;       temp=(struct node*)malloc(sizeof(struct node));       printf("\n Enter new")...