python exercise1

1.

#!/usr/bin/env Python
# coding:utf-8
_author_ = "tom"

'''
@author:houruiyun
@file:2.py
@contact:674211605.qq.com
@time:6/25/172:45 AM
@desc:
'''
for i in range(1,4):
    name = raw_input('please input your name:')
    password = raw_input('your password:')
    if  (name == 'root' and password == 'westos'):
        print 'welcome to user manager system'
        exit (0)
    else:
        print 'the user and password is not matching'
print ('你已经登陆过三次,请十分钟后登陆')



2.打印所有小于10并且大于或等于0的所有偶数; 
打印所有小于10并且大于或等于0的最大偶数 
这里写图片描述

源代码:

# /usr/bin/env python
# coding:utf-8
_author_ = "lvah"

'''
@author:fairy
@file:homework1.py
@time:17-7-5下午11:32
@DESC;
'''
print range(0,10,2)
print range(1,10,2)
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

3.判断一个数是否为质数 
源代码:

#/usr/bin/env python
#coding:utf-8
_author_ = "lvah"

'''
@author:fairy
@file:3.py
@time:17-7-6上午1:43
@DESC;
'''
num = input('请输入数字:')
if num > 1:
    for n in range(2,num):
        if ( num % n ) == 0:
            print num,'不是质数'
            break
    else:
        print num,'是质数'
else:
    print num,'不是质数'
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

这里写图片描述

测试: 
这里写图片描述

这里写图片描述

这里写图片描述

8.创建一用户登陆程序:保存用户的用户名与密码 
新建用户时,判断用户名是否已经存在,若已经存在则报错; 
登陆系统时,确保用户名存在于系统中,密码正确,有三次机会,超过三次则报错 
源代码:

# /usr/bin/env python
# coding:utf-8
_author_ = "lvah"

'''
@author:fairy
@file:8.py
@DESC;
'''
Username = []
Password = []
print '''
    登陆(L)ogin   新建(N)ew
'''


def login():
    if Username == []:
        print  '无用户,请新建用户'
    else:
        count = 0
        while count<3:
            name_in = raw_input('name:')
            pass_in = raw_input('password:')
            if name_in in Username:
                i = Username.index(name_in)
                pass1 = Password[i]
                if pass_in == pass1:
                    print 'welcome to user system'
                    exit(0)
                else:
                    count += 1
            else:
                count += 1
        print 'error'

def new():
    name2 = raw_input('new name:')
    if name2 not in Username:
        Username.append(name2)
        pass2 = raw_input('new password:')
        Password.append(pass2)
        print 'Adding new user successful'
    else:
        print 'error : the user has exists'


def main():
    cho = 'Enter your choice:'
    while True:
        pro = raw_input(cho).lower()
        if pro == 'l':
            login()
        elif pro == 'n':
            new()
        else:
            print 'you can input l,n'

main()
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59

测试: 
这里写图片描述

exercise1 Using Search Engines Prerequisites, Goals, and Outcomes Prerequisites: Before you begin this exercise, you need mastery of the following: • HTML basics: Understand what the Web is and how it works • HTML basics: Understand how web pages are constructed • HTML basics: Understand how search engines work Goals: This assessment will give you practice in using search engines to find specific pieces of information on the World Wide Web and in evaluating web page design. Outcomes: By successfully completing this assignment, you will demonstrate mastery in the following: • Using search engines to find information on the World Wide Web • Evaluating web page design • Understanding the differences between several search engines • Identifying the Uniform Resource Locator (URL) for Web resources Description - Part A Using the search engine of your choice, find URL's for the following: 1. The home pages for three major industrial corporations http://findarticles.com/ http://www.irs.gov/ http://www.irs.gov/ 2. The home page for a college or university http://www.whu.edu.cn/ http://www.tsinghua.edu.cn/ http://www.pku.edu.cn/ 3. The season schedule for a college or professional sports team http://en.wikipedia.org/wiki/College_football 4. The season schedule for a professional arts group (symphony, ballet company, opera company, etc.) http://www.tcg.org/international/resources/other_organizations.cfm 5. A picture of the Washington Monument in Washington, D.C. http://www.google.cn/imgres?imgurl=http://www.rentatour.com/Admin/ManageTour/PARTIES_%2520EVENT/Discover%2520Washington%2520D.C.%2520(Click%2520for%2520Slideshow)/dc_washingtonMonument_01.jpg&imgrefurl=http://www.rentatour.com/slideshow.aspx%3Ftour_detail_id%3D64%26tour_type%3D3&h=400&w=300&sz=12&tbnid=uEi9o3Lb_n6ITM::&tbnh=124&tbnw=93&prev=/images%3Fq%3DWashington%2BMonument%2Bin%2BWashington,%2BD.C%2Bpicture&hl=zh-CN&usg=__R8ekMtk98odW4hadJ4ND5aqQAnw=&sa=X&oi=image_result&resnum=2&ct=image&cd=1 6. A Web page that is, in your opinion, well-designed, interesting, and attracts a lot of "hits" www.google.com.cn 1 The format of it is very clear 2 I can log in it very quickly 3 The picture is very beautiful 4 I can find what I want quickly 5 It is a dynamic web.It is very interesting 7. A Web page that is, in your opinion, poorly designed http://www.whu.edu.cn/ 1 The format of it isn’t very clear 2 I can’t log in it very quickly 3 The picture isn’t very beautiful 4 I can’t find what I want quickly 5 It isn’t a dynamic web.It is very boring. Note that with the URLs for #6 and #7, you should include a list of five things that make the Web pages well-designed and poorly-designed, respectively. Description - Part B Pick one of the topics listed below and conduct three searches on that topic. Each search should use a different search engine (the choice is yours). Record the URLs for the top five sites found by each search (that is, 15 URLs in total). • Stamp collecting • Model railroading • The Golden Gate Bridge Visit each of the top five sites found by each search engine. Then, write a brief statement comparing and contrasting the results of the three searches. State which search engine yielded the best results and list the factors that influenced your opinion www.baidu.com 1 http://www.levelpad.com/791/102830.htm 2http://www.oxford.com.cn/study/exam/yingyu-zuowen/chuzhong-yingyu-zuowen/2006-05-04/12228.html 3 http://www.levelpad.com/791/102830.htm 4 http://www.9sky.com/music/artist/trks/7626 5http://www.ew.com.cn/readonline/jsb/xxjsb/2006/04/2007/01/2007-01-111163.html www.google.com 1 http://en.wikipedia.org/wiki/Stamp_collecting 2 http://www.usps.com/shop/stampcollecting.htm 3http://scholar.ilib.cn/Article.aspx?AIT=QCode&AI=sxda200104014&A=sxda200104014 4 http://www.9sky.com/music/artist/7626 5 http://english.cri.cn/4026/2008/10/11/1481s413585.htm www.yahoo.com 1 http://www.amazon.com/Stamp-Collecting-Stephen-R-Datz/dp/088219030X 2http://www.amazon.com/Stamp-Ultimate-Collecting-Activity-Book/dp/0811833313 3 http://www.mdcstamps.com/safe-parat-stockbooks.htm 4 http://stampcollecting.in/ 5http://rds.yahoo.com/_ylt=A0oGkwymrllJDRwBoMJXNyoA;_ylu=X3oDMTEzb3Z0NzVoBHNlYwNzcgRwb3MDNQRjb2xvA3NrMQR2dGlkA0Y5MTlfMTEz/SIG=129lg6q5d/EXP=1230700582/**http%3a//www.microdatacom.net/safe-parat-stockbooks.htm The web yielded by www.baidu.com and www.google.com is full of advertisement .I think there are useless.However the web yielded by www.yaohoo.com is more useful Tasks To complete this exercise, begin by opening a search engine and performing a search on the first of three companies for requirement number 1 in Part A above. When you find a web site that you would like to use, copy and paste its URL into a text file (You can use Notepad as your text editor) instead of retyping the URL. This approach saves time and reduces the probability of creating a typographical error. Repeat this process until you have found URLs for all of the required web sites. As you build your text file, be sure to save your work often. Submission Submit only the following file: • ex1.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值