Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63589
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'elif': 0.05; 'atlanta': 0.07; 'welcome.': 0.07; '"no"': 0.09; 'function,': 0.09; 'newline': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'typed': 0.09; 'python': 0.11; '""")': 0.16; 'arizona': 0.16; 'bye': 0.16; 'handled.': 0.16; 'ignoring': 0.16; 'inputs': 0.16; 'literals:': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'team?': 0.16; 'typos': 0.16; 'unexpected': 0.16; 'wrote:': 0.18; 'code.': 0.18; '>>>': 0.22; 'input': 0.22; 'import': 0.22; 'coding': 0.22; 'header:User-Agent:1': 0.23; 'script.': 0.24; "i've": 0.25; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'code': 0.31; '"",': 0.31; 'once,': 0.31; 'handled': 0.32; 'beginning': 0.33; "who's": 0.35; 'but': 0.35; 'doing': 0.36; 'hi,': 0.36; 'should': 0.36; 'seconds': 0.37; 'tasks': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'email addr:gmail.com': 0.63; 'myself': 0.63; 'teaching': 0.64; 'taking': 0.65; 'here': 0.66; 'football': 0.84; 'orleans': 0.84; 'patriots': 0.84; 'day!': 0.85 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Constructive Criticism |
| Date | Thu, 09 Jan 2014 10:56:37 +0100 |
| Organization | None |
| References | <8574fa07-af12-4e62-9cbc-3bd00802b6e2@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084bc68.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5252.1389261357.18130.python-list@python.org> (permalink) |
| Lines | 91 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389261357 news.xs4all.nl 2845 [2001:888:2000:d::a6]:33075 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63589 |
Show key headers only | View raw
jeremiahvalerio123@gmail.com wrote:
> Hi, hows it going I've been self teaching myself python, and i typed up
> this small script now i know its not the best the coding is not the best
> but i would like to know of ways to make a small script like this better
> so all constructive critisim is Welcome.
>
>
>
> Here is the link to the code
>
> " http://pastebin.com/5uCFR2pz "
> time.sleep(1)
> import time
> print("Closing in 9 ")
> time.sleep(1)
> import time
> print("Closing in 8 ")
- You should import modules just once, at the beginning of your script.
- Repetetive tasks are best handled with a for-loop, e. g.:
>>> import time
>>> for seconds_left in reversed(range(1, 10)):
... print("Closing in", seconds_left, "seconds")
... time.sleep(1)
...
Closing in 9 seconds
Closing in 8 seconds
Closing in 7 seconds
Closing in 6 seconds
Closing in 5 seconds
Closing in 4 seconds
Closing in 3 seconds
Closing in 2 seconds
Closing in 1 seconds
> user_input = input("\nWhos your favorite Football team? \n 1.Arizona
> Cardinals\n 2.Atlanta Falcons\n 3.Baltimore Ravens\n 4.Buffalo Bills\n
> 5.Miami Dolphins\n 6.Minnesota Vikings \n 7.New England Patriots \n
> 8.New Orleans Saints \n 9.Carolina
[snip]
Python offers triple-quoted strings which may include newline literals:
user_input = input("""
Who's your favorite Football team?
1. Arizona Cardinals
2. Atlanta Falcons
...
""")
> if user_input == "1" :
> print("\nThey suck! BYE!")
>
> elif user_input == "2" :
> print("\nThey suck! BYE!")
>
> elif user_input == "3" :
> print("\nThey suck!BYE!")
[snip]
Ignoring the typos you are taking the same action for all inputs but "17".
So:
if user_input != "17":
print()
print("They suck! BYE!")
You should give some thought how unexpected user input like "", "123",
"whatever" should be handled.
> elif user_input == "no" :
> print("\nAlrighty bye have a nice day! :)\n\nClosing in 10.")
> import time
> time.sleep(1)
> import time
> print("Closing in 9 ")
> time.sleep(1)
> import time
> print("Closing in 8 ")
> time.sleep(1)
> import time
OK, you are doing the count-down thing twice -- time to write a function,
say countdown(), that you can put where you need a count-down instead of the
repetetive code.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Constructive Criticism jeremiahvalerio123@gmail.com - 2014-01-08 21:56 -0800
Re: Constructive Criticism Paul Pittlerson <menkomigen6@gmail.com> - 2014-01-08 22:06 -0800
Re: Constructive Criticism Ben Finney <ben+python@benfinney.id.au> - 2014-01-09 17:09 +1100
Re: Constructive Criticism jeremiah valerio <jeremiahvalerio123@gmail.com> - 2014-01-08 22:16 -0800
Re: Constructive Criticism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 07:03 +0000
Re: Constructive Criticism Peter Otten <__peter__@web.de> - 2014-01-09 10:56 +0100
Re: Constructive Criticism jeremiah valerio <jeremiahvalerio123@gmail.com> - 2014-01-09 12:08 -0800
Re: Constructive Criticism Christopher Welborn <cjwelborn@live.com> - 2014-01-09 14:54 -0600
Re: Constructive Criticism jeremiah valerio <jeremiahvalerio123@gmail.com> - 2014-01-09 13:05 -0800
Re: Constructive Criticism Alister <alister.ware@ntlworld.com> - 2014-01-10 08:56 +0000
Re: Constructive Criticism jeremiah valerio <jeremiahvalerio123@gmail.com> - 2014-01-10 12:26 -0800
Re: Constructive Criticism Chris Angelico <rosuav@gmail.com> - 2014-01-11 07:34 +1100
Re: Constructive Criticism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-10 21:24 +0000
csiph-web