# -*- coding: utf-8 -*-
# !/usr/bin/env python
# @Time : 2018/4/8 0008 上午 12:13
# @Author : 陈元
# @Email : abcmeabc@163.com
# @file : Demo9.py
# 函数的定义
def hello(name):
print("hello {0}".format(name))
print("hello world")
for i in range(1,10):
print(i)
# 缩进
# 冒号
def f():
m = " dddddd ff "
print(len(m))
# if 条件判断
# 数据判断 (字符串) 1.是否为空
# if a.strip(): 有事没事strip去一下空格
# d if type(a) == "dict"
d = dict(a=1)
# 不推荐用
# if type(d) == "dict":
# print("{0} is dict".format(d))
# 一般这样使用,isinstance判断类型
if isinstance(d,dict):
print("{0} is dict".format(d)) # 可见用format,方便了许多
# 字典和字符串相加怎么办
print(str(d)+"hello world") #强制类型转换
m = [x for x in range(1,10)]
print(len(d))
# if 条件判断:
# 逻辑操作。。。
# 。。。
age = raw_input("Please input your age:")
# if age>=18:
# if int(age)>=18:
if age.strip():
# print("你输入的年龄不符合要求:")
if age.strip().isdigit(): #isdigit 判断是数字,是数字返回true
if int(age)>=18:
print("你是一个成年人")
else:
print("你还是一个小屁孩!")
else:
print("你输入的不是数字!")
else:
print("你输入的只有空格,你SB吧!")
number = raw_input("input number:")
if number > 0:
print("{0} 是正数。".format(number))
elif number < 0:
print("{0} 是负数。".format(number))
else:
print("输入的是{0}。".format(number))