'''
@Author: your name
@Date: 2020-07-21 09:51:06
@LastEditTime: 2020-07-21 10:15:50
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day15.py
'''
# -*- coding: utf-8 -*- # Q58
import re
# Question 54
# 读取邮箱地址中的公司名称
def Q54():
email = "john@google.com elise@python.com"
pattern = "(\w+)@(\w+).com" # 正则,带括号的是要输出的内容
ans=re.findall(pattern, email)
print(ans)
# Question 55
# 读取输入中的数字
def Q55():
r=input()
# print(r)
pattern="\d"
ans=re.findall(pattern,r)
print(ans)
# Question 56
# Print a unicode string "hello world".
def Q56():
uHello=u"Hello,World!" # Use u'strings' format to define unicode string.
print(uHello)
# Question 57
# 读取ascii码转变为utf-8
def Q57():
s=input()
u=s.encode('utf-8') # Use unicode()/encode() function to convert.
print(u)
# Question 58
# Write a special comment to indicate a Python source code file is in unicode.
# 见文件开始
# Question 59
# 计算1/2+2/3+3/4+...+n/n+1
def Q59():
n=int(input("n="))
sum=0
for i in range(1,n+1):
sum+=float(i)/float(i+1)
print(round(sum,2)) # round 保留两位小数
if __name__ == "__main__":
# Q54()
# Q55()
# Q56()
# Q57()
Q59()