#! /usr/bin/env python | |
import os,subprocess | |
from stat import * | |
#! /bin/bash | |
clear | |
_rc = subprocess.call(["clear"]) | |
sum=0 | |
sum=0 | |
i="y" | |
i="y" | |
echo " Enter one no." | |
print(" Enter one no.") | |
read n1 | |
n1 = raw_input() | |
echo "Enter second no." | |
print("Enter second no.") | |
read n2 | |
n2 = raw_input() | |
while [ $i = "y" ] do echo "1.Addition" echo "2.Subtraction" echo "3.Multiplication" echo "4.Division" echo "Enter your choice" read ch case $ch in 1)sum=`expr $n1 + $n2` echo "Sum = $sum";; 2)sum=`expr $n1 - $n2` echo "Sub = $sum";; 3)sum=`expr $n1 \* $n2` echo "Mul = $sum";; 4)sum=`expr $n1 / $n2` echo "Div = $sum";; *)echo "Invalid choice";; esac echo "Do u want to continue (y/n)) ?" read i if [ $i != "y" ] then exit fi done | |
while (i == ""y"" ): print("1.Addition") print("2.Subtraction") print("3.Multiplication") print("4.Division") print("Enter your choice") ch = raw_input() if ( ch == '1'): sum=os.popen("expr "+str(n1)++str(n2)).read() print("Sum = " + str(sum)) elif ( ch == '2'): sum=os.popen("expr "+str(n1)+" - "+str(n2)).read() print("Sub = " + str(sum)) elif ( ch == '3'): sum=os.popen("expr "+str(n1)+" * "+str(n2)).read() print("Mul = " + str(sum)) elif ( ch == '4'): sum=os.popen("expr "+str(n1)+" / "+str(n2)).read() print("Div = " + str(sum)) else: print("Invalid choice") print("Do u want to continue (y/n)) ?") i = raw_input() if (i != ""y"" ): exit() | |
ÿ |