#!/usr/bin/python
#-*- coding:utf8 -*-
from __future__ import division
#简单的讲解if的使用 elif switch的使用
def cmp(a, b):
if a > b:
print "a is bigger than b"
elif a == b:
print "a is eual to b"
else:
print "a is smaller than b"
#a = input("please enter a num: ")
#b = input("please enter other num: ")
#cmp(a,b)
#现在来介绍raw_input的使用
num = raw_input("please enter a num: ")
num = int(num)
print "the num is: ", num
string = raw_input("please enter a string: ");
print "the string is: ",string
#现在来演示elif的使用
score = input("enter the score: ")
if(score >= 90) and (score<=100):
print "A"
elif(score >= 80) and (score <= 90):
print "B"
elif(score >= 70) and (score <= 80):
print "C"
elif(score >= 60) and (score <= 70):
print "D"
else:
print "E"
#现在来演示一下switch效果 注意 python中没有switch关键字额
#from __future__ import division
m = 1
n = 2
operator = "/"
result = {
"+": m + n,
"-": m - n,
"*": m * n,
"/": m / n
}
print "the result is: ",result.get(operator)
#-*- coding:utf8 -*-
from __future__ import division
#简单的讲解if的使用 elif switch的使用
def cmp(a, b):
if a > b:
print "a is bigger than b"
elif a == b:
print "a is eual to b"
else:
print "a is smaller than b"
#a = input("please enter a num: ")
#b = input("please enter other num: ")
#cmp(a,b)
#现在来介绍raw_input的使用
num = raw_input("please enter a num: ")
num = int(num)
print "the num is: ", num
string = raw_input("please enter a string: ");
print "the string is: ",string
#现在来演示elif的使用
score = input("enter the score: ")
if(score >= 90) and (score<=100):
print "A"
elif(score >= 80) and (score <= 90):
print "B"
elif(score >= 70) and (score <= 80):
print "C"
elif(score >= 60) and (score <= 70):
print "D"
else:
print "E"
#现在来演示一下switch效果 注意 python中没有switch关键字额
#from __future__ import division
m = 1
n = 2
operator = "/"
result = {
"+": m + n,
"-": m - n,
"*": m * n,
"/": m / n
}
print "the result is: ",result.get(operator)