天天看點

python 學習記錄一

#!/usr/bin/pytholn

# -*- coding: UTF-8 -*-

import math

import sys

def print_13():

#for i in range(10):

man_age = int(raw_input('enter input age:\n'))

if man_age >= 10 and man_age <= 12:

sex = str(raw_input('please input sex : M is the male or F a female and your is age :\n'))

for i in range(10):

print 'Can you join the team!'

print 'Thank you for your cooperation'

    #break

else:

     print "You are not satisfied"     

print print_13()

def print_10():

n = int(raw_input('enter number:\n'))

if n % 3 ==0 and n % 5 == 0:

print 'N can be divisible by 3 or 5 '

print 'N not be divisible by 3 or 5'

#print_10()

def print_price():

discount = 0

pice = float(raw_input("Please enter the purchase price:\n"))

if pice >= 50 and pice <= 100:

discount = 0.1

print 'The discount price is 10 %.'

elif pice > 100:

discount = 0.2

print 'The discount price is 20%.'

print 'sorry ! is not discount.'

print pice * discount

#print_price()

def print_huashi():

temperature = float(raw_input("please input temperature :\n"))

c = 5.0 / 9 * (temperature - 3)

print c

#print_huashi()

def print_sort():

l = [0,2,3,4,5]

k = []

for i in l:

k.insert(0,i)

print k

#print_sort()

def print_number():

str_num = '22222mmmm12232132312wqweqeqw'

result = 0

for i in str_num:

if i in '0123456789':

result += 1

print result

#print_number()

def print_50():

result = ''

for i in range(1,51,1):

if i == 50:

result += str(i)

result += str(i) +" "

#print_50()

def list_print():

    alist = [123,'abc',4.56,['inner','list'],7-9j]

#print list_print()

def  print_movices():

 movices = ["The Holey Grail","The life of Brian","The Meaning of life"]

 print movices[1]

#print_movices()

#比如abcd輸出每一次減少一個字母輸出

def print_shusu():

s = 'abcde'

i = -1

for i in range(-1,-len(s),-1):

print s[:i]

#print_shusu()

def print_three():

l = []

for i in range(3):

x = int(raw_input('three number\n'))

l.append(x)

l.sort()

print l

#print_three()

print("----------------")

#一個整數,它加上100後是一個完全平方數,再加上268又是一個完全平方數,請問該數是多少

def print_math():

for i in range(100000):

x = int(math.sqrt(i + 100 ))

y = int(math.sqrt(i + 268 ))

if(x * x == i + 100) and (y * y == i + 268):

print i

#print_math()

#有四個數字:1、2、3、4,能組成多少個互不相同且無重複數字的三位數?各是多少?

def  print_sort():

for i in range(1,5) :

    for j in range(1,5) :

        for k in range(1,5) :

           if(i != k ) and (i != j ) and (j !=k ):

                print i, j, k

#print_sort()                 

本文轉自 知止内明 51CTO部落格,原文連結:http://blog.51cto.com/357712148/1983378,如需轉載請自行聯系原作者