[Tutor] Python Programming

2014-08-27 Thread Jake
To whom it may concern,
My name is Jake and I have recently started the GCSE computing course with 
school. As summer holidays homework we have been asked to make a game. So I 
have made a Capital Cities Quiz. When I run my program this part of my coding 
does not seem to work:
answera = input()
if answera == ["Oslo" or "oslo"]:
print ("CORRECT!!")
score = score + 1
else:
print("INCORRECT!!")

When I type Oslo or oslo as my answer it keeps telling me that it is incorrect. 
I was wondering if it would be possible for you to tell me what I have done 
wrong and hopefully point me in the right direction.
I look forward to hearing from you,

Jake
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 20, Issue 11

2005-10-06 Thread jake skipper
Please take me off of your mailing list.[EMAIL PROTECTED] wrote:
Send Tutor mailing list submissions totutor@python.orgTo subscribe or unsubscribe via the World Wide Web, visithttp://mail.python.org/mailman/listinfo/tutoror, via email, send a message with subject or body 'help' to[EMAIL PROTECTED]You can reach the person managing the list at[EMAIL PROTECTED]When replying, please edit your Subject line so it is more specificthan "Re: Contents of Tutor digest..."Today's Topics:1. Re: need help to understand terms for desinging a program(paul brian)2. Re: FW: Help Needed (Alan Gauld)3. How to strip both single and double quotes (Dick Moores)--Message: 1Date: Wed, 5 Oct 2005 10:22:48 +0100From: paul brian <[EMAIL PROTECTED]>Subject: Re: [Tutor] need he!
 lp to
 understand terms for desinging aprogramTo: "Hameed U. Khan" <[EMAIL PROTECTED]>Cc: tutor@python.orgMessage-ID:<[EMAIL PROTECTED]>Content-Type: text/plain; charset=ISO-8859-1This is a pretty big question, and it would be easier to answer if youcan give us more details about what you want to do.It seems you want to inspect outgoing mails (possibly rewrite theiraddresses?) before the mails are sent out.If you are looking to send out emails to a list then I suggest lookingat mailman - a python mailing list manager.If you want to use python to examine mail messages and do not carewhat mailserver (MTA) you use you could try exim instead of qmail andthen try exim-python. http://botanicus.net/dw/exim-python/exim-4.32py1.htmlOn 10/5/05, Hameed U. Khan <[EMAIL PROTECTED]>wrote:> Hi,> I need to make a program which !
 will
 accomplish following. I dont> need the code. I want to make it myself. But I need guidance from you> people because I am not a good programmer. I need help in> understanding following terms.>> " qmail-queue reads a mail message from descriptor 0. It> then reads envelope information from descriptor 1. It> places the message into the outgoing queue for future> delivery by qmail-send.>> The envelope information is an envelope sender address> followed by a list of envelope recipient addresses. The> sender address is preceded by the letter F and terminated> by a 0 byte. Each recipient address is preceded by the> letter T and terminated by a 0 byte. The list of recipi-> ent addresses is terminated by an extra 0 byte. If qmail-> queue sees end-of-file before the extra 0 byte, it aborts> without placing the message into the queue.">> I want to inspect!
  messages
 before passing them to actuall qmail-queue> program.> Thanks in advance for your help.> --> Regards,> Hameed U. Khan> Registered Linux User #: 354374> ___> Tutor maillist - Tutor@python.org> http://mail.python.org/mailman/listinfo/tutor>Paul Brianm. 07875 074 534t. 0208 352 1741--Message: 2Date: Wed, 5 Oct 2005 10:44:09 +0100From: "Alan Gauld" <[EMAIL PROTECTED]>Subject: Re: [Tutor] FW: Help NeededTo: "Daniel Watkins" <[EMAIL PROTECTED]>, Message-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; format=flowed; charset="UTF-8";reply-type=original> When I am in Python Shell of the IDLE GUI, when I click Edit/RunYou shouldn't be running scripts when in the shell, it
 executes them immediately.You use edit/run when working in a script file window.HTH,Alan G --Message: 3Date: Wed, 05 Oct 2005 02:43:47 -0700From: Dick Moores <[EMAIL PROTECTED]>Subject: [Tutor] How to strip both single and double quotesTo: tutor@python.orgMessage-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset="iso-8859-1"; format=flowedI'm writing a script that takes any text and outputs to a file a list of duples (k, word) where k is the number of occurrences of word in the text.The text will contain "words" beginning or ending with non-alphabetic characters. To strip them off I use string.strip([chars]). My question is how to use strip just once to get rid of both kinds of quotes, single and double. It seems necessary to do it something like this:# L is the original list of "words" in the text.newL =
 []for word in L:word = lower(word)newWord = word.strip(".,!?;:&*'=-> newWord2 = newWord.strip('.,!?;:&*"=-> word = newWord2newL.append(word)But is it? Have I missed something?Thanks,Dick Moores--___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutorEnd of Tutor Digest, Vol 20, Issue 11*
		Yahoo! for Good 
Click here to donate to the Hurricane Katrina relief effort. 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] newbie needs help with rpg code in python

2008-03-16 Thread jake cooper

Hey everyone :)
I'm extremely new to programming as python is the first language I have 
attempted to learn (and I only started yesterday!)
I decided to start learning by attempting to create a short textbased rpg.
My progress so far has been rather haphazard to say the least, but I think I 
might be finally getting somewhere with this.
 
Below is my code as it currently exists:
 
#Character stats (lv 1)
max_c_hp = 180max_c_mp = 30c_strength = 50c_defence = 25c_agility = 
50c_fireball = 60c_heal = 100
#Skeleton stats (lv1)
max_e_hp = 230max_e_mp = 30e_strength = 48e_defence = 30e_agility = 
50e_fireball = 75
#Battle functions
def battle_start(): #Allows player to choose to fight or runprint 'A 
skeleton appears from the shadows!'fight_or_run = int(raw_input ('Do you 
fight[1] or run[2]?'))if fight_or_run == 1:print 'You engage the 
enemy.'battle_menu() #Sends player to battle menuelif fight_or_run 
== 2:escape()
def battle_menu(): #Allows player to choose primary action in battleprint 
'Attack[1]'print 'Magic[2]'print 'Escape[3]'menu_selection = 
int(raw_input ('Enter your choice.'))if menu_selection == 1:
c_attack()elif menu_selection == 2:c_m_attack()elif 
menu_selection == 3:escape()
def c_attack(): #Processes damage dealt by a physical attackdamage_to_enemy 
= c_strength - e_defence print 'You inflicted', damage_to_enemy, "points of 
damage to your enemy"  #shows damage dealttemp_e_hp - damage_to_enemy 
#!!!attempts to deduct damage_to_enemy from temp_e_hp!!!print temp_e_hp
if temp_e_hp == 0:victory()else:battle_menu()
def escape(): #Allows player to escape from a battleprint 'You attempt to 
flee the battle!'if c_agility > e_agility:print 'You succssfully 
escape' #!!!Need to quit battle and return to field!!!elif c_agility < 
e_agility:print 'You fail to escape and miss a battle turn.' #!!!Need 
to find a way to miss a turn after tb system written!!!battle_menu()
elif c_agility == e_agility:print 'You fail to escape and are forced to 
contine engaging the enemy.'battle_menu() #Sends player to battle menu
#Battle flowtemp_c_hp = max_c_hp # creates a temporary stat for characters hp, 
just to be used in this battletemp_e_hp = max_e_hp #creates a temporary stat 
for enemies hp, just to be used in this battlebattle_start() # launches battle 
sequence
As you can see, I've annotated it rather thoroughly to display the (simple) 
processes being performed and there are several issues slowing my progress.  
The main one I need help with is in the c_attack function.  For some reason, I 
cant manage to subtract damage_to_enemy from temp_e_hp.  Any help with my 
script (especially with this problem) would be highly appreciated.
And for one final question, is there a way to use random percentages of a 
number.  For example, to subtract 80 - 120 % of damage_to_enemy from temp_e_hp?
 
Sorry for all the questions, but I'm totally stumped at the moment.
Thanks for your time
 
-Jake
_
Free games, great prizes - get gaming at Gamesbox. 
http://www.searchgamesbox.com___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python

2013-08-15 Thread Jake Wohldmann
Hello I am a beginner to using any type of script.  How long does it take
to become fluent at a script?  I will only be able to practice python on
weekends since school is starting.  I was also wondering if I could use
python on my android phone.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python

2013-08-18 Thread Jake Wohldmann
Hello I am a beginner to using any type of programming lanhuage  How long
does it take to become fluent at a script? Do you know and good sites to
learn python?  I will only be able to practice python on weekends since
school is starting.  I was also wondering if I could use python on my
android phone.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Alice_in_wonderland Question

2014-05-04 Thread Jake Blank
Hi,
So I'm doing a problem on the Alice_in_wonderland.txt where I have to write
a program that reads a piece of text from a file specified by the user,
counts the number of occurrences of each word, and writes a sorted list of
words and their counts to an output file. The list of words should be
sorted based on the counts, so that the most popular words appear at the
top. Words with the same counts should be sorted alphabetically.

My code right now is

word_count = {}
file = open ('alice_in_wonderland.txt', 'r')
full_text = file.read().replace('--',' ')
full_text_words = full_text.split()

for words in full_text_words:
stripped_words = words.strip(".,!?'`\"- ();:")
try:
word_count[stripped_words] += 1
except KeyError:
word_count[stripped_words] = 1

ordered_keys = word_count.keys()
sorted(ordered_keys)
print ("All the words and their frequency in", 'alice in wonderland')
for k in ordered_keys:
print (k, word_count[k])

The Output here is just all of the words in the document NOT SORTED by
amount of occurrence.
I need help sorting this output of words in the Alice_in_wonderland.txt, as
well as help asking the user for the input information about the files.

If anyone could give me some guidance you will really be helping me out.

Please and Thank you
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Alice_in_wonderland Question

2014-05-05 Thread Jake Blank
Hi,

I finally got it.
This was the code:
for k in sorted(word_count, key=lambda x:word_count[x], reverse=True):
print (k, word_count[k])

The only question i have now is how to limit the amount of returns the
program runs to the first 15 results.




On Sun, May 4, 2014 at 10:19 PM, Brian van den Broek <
brian.van.den.br...@gmail.com> wrote:

> Hi Jake,
>
> Please do be sure to use Reply All rather than just Reply. I'm sending
> my reply and and quotes from yours to the list; that way, others can
> follow along, learn and help.
>
> Also, in general, reply under the messages to which you respond,
> ideally trimming what isn't needed away. (You will see that is what I
> have done below.)  Yes, that's not how email is used outside of
> technical circles. I'd maintain the technical circles's preference for
> not top posting is right. But, right or wrong, it is what those whom
> you are asking for free help prefer, so it is prudent to do it,
> gritting your teeth if you must :-)
>
> On 4 May 2014 21:36, Jake Blank  wrote:
> > Hey Thanks for responding.
> >
> > So now my code looks like this:
> > from wordtools import extract_words
> >
> > source_filepath=input("Enter the path to the source file:")
> > dest_filepath =input("Enter the path to the destination file:")
> >
> > sourcef=open(source_filepath, 'r')
> > destf=open(dest_filepath, 'w')
> > for line in sourcef:
> > destf.write(line)
> > file=input ("Would you like to process another file?(Y/N):")
> > if file== "Y":
> > source_filepath=input("Enter the path to the source file:")
> > dest_filepath =input("Enter the path to the destination file:")
> > else:
> > word_count = {}
> > file = open (source_filepath, 'r')
> > full_text = file.read().replace('--',' ')
> > full_text_words = full_text.split()
> >
> > for words in full_text_words:
> > stripped_words = words.strip(".,!?'`\"- ();:")
> > try:
> > word_count[stripped_words] += 1
> > except KeyError:
> > word_count[stripped_words] = 1
> >
> > ordered_keys = word_count.keys()
> > sorted(ordered_keys)
> > print ('This is the output file for Alice in Wonderland')
> > for k in sorted(ordered_keys):
> > print (k, word_count[k])
> >
> > The first part about the user specifying the file is a little off but
> > besides that I am able to return all of the words in the story with the
> > number of times they occur alphabetically.  In order to return the sorted
> > list by number of times that each word occurs I am a little confused if i
> > have to change something in my print statement?  I understand how i have
> to
> > sort the words by their associated values i'm confused where in my code i
> > would do that.
> >
> > Thanks, Jake
>
> > On Sun, May 4, 2014 at 9:16 PM, Brian van den Broek
> >  wrote:
> >>
> >> On May 4, 2014 8:31 PM, "Jake Blank"  wrote:
>
>
> 
>
>
> >> Hi Jake,
> >>
> >> You are sorting the dictionary keys by the keys themselves, whereas
> >> what you want is the keys sorted by their associated values.
> >>
> >> Look at the key parameter in
> >> https://docs.python.org/3.4/library/functions.html#sorted.
> >>
> >> To get you started, here is an example in the vicinity:
> >>
> >> >>> data = ['abiab', 'cdocd', 'efaef', 'ghbgh']
> >> >>> sorted(data)
> >> ['abiab', 'cdocd', 'efaef', 'ghbgh']
> >> >>> sorted(data, key=lambda x:x[2])
> >> ['efaef', 'ghbgh', 'abiab', 'cdocd']
> >> >>> def get_third(x): return x[2]
> >> ...
> >> >>> sorted(data, key=get_third)
> >> ['efaef', 'ghbgh', 'abiab', 'cdocd']
> >> >>>
> >>
> >> In case the lambda version is confusing, it is simply a way of doing
> >> the get_third version without having to create a function outside of
> >> the context of the sorted expression.
> >>
> >> If that sorts you, great. If not, please do ask a follow-up. (I was
> >> trying not to do it for you, but also not to frustrate by giving you
> >> too little of a push.)
>
>
> So, the code in your s

Re: [Tutor] Alice_in_wonderland Question

2014-05-05 Thread Jake Blank
To figure that last part out I just did a simple if statement.
for k in sorted(word_count, key=lambda x:word_count[x], reverse=True):
if word_count[k] >=300:
print (k, word_count[k])
And the output was correct.

I did have one more question though.

import os
from wordtools import extract_words

source_filepath=input("Enter the path to the source file:")
dest_filepath =input("Enter the path to the destination file:")

sourcef=open(source_filepath, 'r')
destf=open(dest_filepath, 'w')
for line in sourcef:
destf.write(line)
file=input ("Would you like to process another file?(Y/N):")
if file== "Y":
source_filepath=input("Enter the path to the source file:")
dest_filepath =input("Enter the path to the destination file:")
else:

This code asks the user for a source/dest_filepath.
I'm wondering how I can make it so the program can tell if the
source/dest_filepath the user entered is actually a program on the computer.

Also i have to ask the user if they would like to "process another
file(Y/N)?" and I'm not sure where to put that.


On Sun, May 4, 2014 at 10:38 PM, Jake Blank  wrote:

> Hi,
>
> I finally got it.
> This was the code:
> for k in sorted(word_count, key=lambda x:word_count[x], reverse=True):
> print (k, word_count[k])
>
> The only question i have now is how to limit the amount of returns the
> program runs to the first 15 results.
>
>
>
>
> On Sun, May 4, 2014 at 10:19 PM, Brian van den Broek <
> brian.van.den.br...@gmail.com> wrote:
>
>> Hi Jake,
>>
>> Please do be sure to use Reply All rather than just Reply. I'm sending
>> my reply and and quotes from yours to the list; that way, others can
>> follow along, learn and help.
>>
>> Also, in general, reply under the messages to which you respond,
>> ideally trimming what isn't needed away. (You will see that is what I
>> have done below.)  Yes, that's not how email is used outside of
>> technical circles. I'd maintain the technical circles's preference for
>> not top posting is right. But, right or wrong, it is what those whom
>> you are asking for free help prefer, so it is prudent to do it,
>> gritting your teeth if you must :-)
>>
>> On 4 May 2014 21:36, Jake Blank  wrote:
>> > Hey Thanks for responding.
>> >
>> > So now my code looks like this:
>> > from wordtools import extract_words
>> >
>> > source_filepath=input("Enter the path to the source file:")
>> > dest_filepath =input("Enter the path to the destination file:")
>> >
>> > sourcef=open(source_filepath, 'r')
>> > destf=open(dest_filepath, 'w')
>> > for line in sourcef:
>> > destf.write(line)
>> > file=input ("Would you like to process another file?(Y/N):")
>> > if file== "Y":
>> > source_filepath=input("Enter the path to the source file:")
>> > dest_filepath =input("Enter the path to the destination file:")
>> > else:
>> > word_count = {}
>> > file = open (source_filepath, 'r')
>> > full_text = file.read().replace('--',' ')
>> > full_text_words = full_text.split()
>> >
>> > for words in full_text_words:
>> > stripped_words = words.strip(".,!?'`\"- ();:")
>> > try:
>> > word_count[stripped_words] += 1
>> > except KeyError:
>> > word_count[stripped_words] = 1
>> >
>> > ordered_keys = word_count.keys()
>> > sorted(ordered_keys)
>> > print ('This is the output file for Alice in Wonderland')
>> > for k in sorted(ordered_keys):
>> > print (k, word_count[k])
>> >
>> > The first part about the user specifying the file is a little off but
>> > besides that I am able to return all of the words in the story with the
>> > number of times they occur alphabetically.  In order to return the
>> sorted
>> > list by number of times that each word occurs I am a little confused if
>> i
>> > have to change something in my print statement?  I understand how i
>> have to
>> > sort the words by their associated values i'm confused where in my code
>> i
>> > would do that.
>> >
>> > Thanks, Jake
>>
>> > On Sun, May 4, 2014 at 9:16 PM, Brian van den Broek
>> >  wrote:
>> >>
>> >> On May 4, 2014 8:31 PM, "