# -*- coding: utf-8 -*-"""
Created on Fri Jun 21 15:52:54 2019
@author: Administrator
"""
a=12
a
print(a)
num=1
string="1"
num2=int(string)print(num+num2)
words='words'*3print(words)
word='a loooooong word'
num=12
string='bang!'
total=string*(len(word)-num)print(total)
name='my name is Mike'print(name[0])print(name[-4])print(name[11:15])print(name[5:])print(name[:5])
phone_number='1386-666-0006'
hiding_number=phone_number.replace(phone_number[:9],'*'*9)print(hiding_number)
city=input("write down the name of city:")
url="http://apistore.baidu.com/microservice/weather?cityp/inyin={}".format(city)deffahrenheit_converter(C):
fahrenheit=C*9/5+32returnstr(fahrenheit)+'°F'
C2F=fahrenheit_converter(35)print(C2F)deftrapezoid_area(base_up,base_down,height):return1/2*(base_up+base_down)*height
trapezoid_area(1,2,3)
trapezoid_area(base_up=1,base_down=2,height=3)file=open('/Users/Hou/Desktop/text.txt','w')file.write('Hello World')abs(-10)>len('length of this word')42>'the answer'42=='the answer'42!='the answer'
album=[]
album =['Black Star','David Bowie',25,True]
album.append('new song')print(album[0],album[-1])'Black Star'in album
the_Eddie ='Eddie'
name ='Eddie'
the_Eddie == name
the_Eddie is name
1<3and2<5#True1<3and2>5#False1<3or2>5#True1>3or2>5#Falsedefaccount_login():
password =input('Password:')if password =='12345':print('Login success!')else:print('Wrong password or invalid input!')
account_login()
account_login()
password_list =['*#*#','12345']defaccount_login():
password =input('Password:')
password_correct = password == password_list[-1]
password_reset = password == password_list[0]if password_correct:print('Login success!')elif password_reset:
new_password =input('Enter a new password:')
password_list.append(new_password)print('Your password has changed successfully!')
account_login()else:print('Wrong password or invalid input!')
account_login()
account_login()for num inrange(1,11):print(str(num)+' + 1 =',num +1)
songslist =['Holy Diver','Thunderstruck','Rebel Rebel']for song in songslist:if song =='Holy Diver':print(song,' - Dio')elif song =='Thunderstruck':print(song,' - AC/DC')elif song =='Rebel Rebel':print(song,' - David Bowie')for i inrange(1,10):for j inrange(1,10):print('{} X {} = {}'.format(i,j,i*j))while1<3:print('1 is smaller than 3')
count =0whileTrue:print('Repeat this line !')
count = count +1if count ==5:break
fruit =['pineapple','pear']
fruit.insert(1,'grape')print(fruit)
fruit[0:0]=['Orange']print(fruit)
periodic_table =['H','He','Li','Be','B','C','N','O','F','Ne']print(periodic_table[0])print(periodic_table[-2])