Re: [Tutor] URGENT: PYTHON QUESTION

2016-03-31 Thread Joel Goldstick
direct your question to tutor@python.org.  Also provide the results you
have gotten from your code, and what you think is wrong

On Thu, Mar 31, 2016 at 7:46 AM, accessmuah  wrote:

> Hi
>
>
>
> Pls, helped review it as i cant proceed to the next stage
>
> def manipulate_data(kind, data):
> if kind == 'list':
> return list(data)[::-1]
> elif kind == 'set':
> data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
> return set(data)
> elif kind == 'dictionary':
> return dict.keys(data)
> manipulate_data("list", range(1,6))
> manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA",
> "AFRICA"})
> manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3,
> "grapes": 45})
>
>
>
>
> I
> DS LAB
> Create a function manipulate_data that does the following
> Accepts as the first parameter a string specifying the data structure to
> be used "list", "set" or "dictionary" Accepts as the second parameter the
> data to be manipulated based on the data structure specified e.g [1, 4,
> 9, 16, 25] for a list data structure Based off the first parameter
>
>- return the reverse of a list or
>- add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return
>the resulting set
>- return the keys of a dictionary
>
>
> Thanks
>
> Regards
>
> Shittu
>
>
> IF YOU THINK YOU CAN'T, YOU CAN'T; IF YOU YOU THINK YOU CAN, YOU CAN !!!
> N.G.U
>
>
>
>
>


-- 
Joel Goldstick
http://joelgoldstick.com/ 
http://cc-baseballstats.info/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fw: URGENT: PYTHON QUESTION

2016-03-31 Thread accessmuah via Tutor
Hi,
Pls, assist with this QuestionKindly stroll to the end
DS LABCreate a function manipulate_data that does the followingAccepts as the 
first parameter a string specifying the data structure to be used "list", "set" 
or "dictionary" Accepts as the second parameter the data to be manipulated 
based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data 
structure Based off the first parameter   
   - return the reverse of a list or
   - add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
resulting set
   - return the keys of a dictionary


My Answer below - Kindly helped reviewed it
def manipulate_data(kind, data):     if kind == 'list':         return 
list(data)[::-1]     elif kind == 'set':         data=set({"a", "b", "c", "d", 
"e", "ANDELA", "TIA", "AFRICA"})        return set(data)     elif kind == 
'dictionary':         return dict.keys(data) manipulate_data("list", 
range(1,6)) manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", 
"AFRICA"})manipulate_data("dictionary", {"apples": 23, "oranges": 15, 
"mangoes": 3, "grapes": 45})

CODE RESULT


 But i cant proceed to next stage...see error below   Pls assist



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


Re: [Tutor] Fw: URGENT: PYTHON QUESTION

2016-03-31 Thread Steven D'Aprano
On Thu, Mar 31, 2016 at 12:47:21PM +, accessmuah via Tutor wrote:
> Hi,
> Pls, assist with this QuestionKindly stroll to the end

> DS LABCreate a function manipulate_data that does the followingAccepts 
> as the first parameter a string specifying the data structure to be 
> used "list", "set" or "dictionary" Accepts as the second parameter the 
> data to be manipulated based on the data structure specified e.g [1, 
> 4, 9, 16, 25] for a list data structure Based off the first parameter
>- return the reverse of a list or
>- add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
> resulting set
>- return the keys of a dictionary
> 
> 
> My Answer below - Kindly helped reviewed it
> def manipulate_data(kind, data):     if kind == 'list':         return 
> list(data)[::-1]     elif kind == 'set':         data=set({"a", "b", 
> "c", "d", "e", "ANDELA", "TIA", "AFRICA"})        return set(data)     
> elif kind == 'dictionary':         return 
> dict.keys(data) manipulate_data("list", 
> range(1,6)) manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", 
> "TIA", "AFRICA"})manipulate_data("dictionary", {"apples": 23, 
> "oranges": 15, "mangoes": 3, "grapes": 45})

Unfortunately your code has been mangled by the email. Can you try 
sending it again WITHOUT using Yahoo's "Rich Text" (HTML mail)?

I will try to reverse-engineer what you meant:

def manipulate_data(kind, data):
    if kind == 'list':
        return list(data)[::-1]
    elif kind == 'set':
        data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
        return set(data)
elif kind == 'dictionary':
        return dict.keys(data) 

manipulate_data("list", range(1,6)) 
manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
"grapes": 45})


Is that what you intended?



> CODE RESULT
> 
> 
>  But i cant proceed to next stage...see error below   Pls assist

I looked below, but you have not included the error. Perhaps you 
included it as an attachment? In that case, it would probably be 
deleted, and if it is a screen-shot, it will be useless to anyone who is 
blind or visually impaired and reading this using a screen reader.

Please COPY and PASTE the text of the error into your email.






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


Re: [Tutor] Best tool for programming interactive games in Python

2016-03-31 Thread Oscar Benjamin
On 30 March 2016 at 00:26, Alan Gauld  wrote:
> On 29/03/16 22:17, Oscar Benjamin wrote:
>>
>> On 29 Mar 2016 22:20, "Alan Gauld" > > wrote:
>>
>> > investigate. And of course there is OpenGL which plays very
>> > well with MacOSX.
>>
>> OpenGL plays nicely with Windows and Linux as well.
>>
>
> But not so well as MacOS X because the OS itself (or the GUI part) is
> written in/for OpenGL. So in addition to raw OpenGL you also get to
> mix n' match the OSX graphics libraries. You can't do that as easily
> in X or Windows is an add-on library, not a native part of the OS.

That's interesting. I've used OpenGL on Windows and Linux but not on
OSX so I'm not sure exactly what you mean. Modern Linux desktops
(Unity, Gnome3, KDE4, etc.) use OpenGL-based compositing just like OSX
does and I'm fairly sure Android does as well. Does it just work out
better on OSX?

I know that work is under way to replace X itself with Wayland and
reimplement the core toolkits (Gtk, Qt, etc) on top of Wayland with
OpenGL as the core and without the vagaries of the X protocol and
without needing the DRI2 extension. Perhaps that would lead to the
sort of situation that there is on OSX...

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


Re: [Tutor] Best tool for programming interactive games in Python

2016-03-31 Thread Alan Gauld
On 31/03/16 20:27, Oscar Benjamin wrote:

>>> OpenGL plays nicely with Windows and Linux as well.
>>
>> mix n' match the OSX graphics libraries. You can't do that as easily
>> in X or Windows is an add-on library, not a native part of the OS.
> 
> That's interesting. I've used OpenGL on Windows and Linux but not on
> OSX so I'm not sure exactly what you mean. 

I can't speak for Linux because, although it's my main platform
I've not done much graphics on it. But on Windows the core OS APIs
all use a device context or GDI object to do their painting. To
use OpenGL you need to bridge between the GDI of native windows
and the OpenGL libraries. If you want to draw a moving string for
instance you need to either use the Windows graphics system
or the OpenGL system. In MacOS X the ODS system is OpenGL so
you can use the native API interleaved with your OpenGL code.

> (Unity, Gnome3, KDE4, etc.) use OpenGL-based compositing just like OSX
> does and I'm fairly sure Android does as well. Does it just work out
> better on OSX?

That's news to me, I thought they(Linux) all worked through the
X layers (Xlib, Xt etc).

> I know that work is under way to replace X itself with Wayland and
> reimplement the core toolkits (Gtk, Qt, etc) on top of Wayland with
> OpenGL as the core

Yes, and at that point I'd expect Linux to be as seamless as MacOS.
But for now it seems to me that you still have to initialise libraries
and explicitly link your OpenGL objects to your OS (X)windows etc.
In short you have to tell the OS GUI that you are choosing to render
on OpenGL and/or use the OpenGL library routines to do any drawing.
It's a one or the other approach.

In MacOS it's (almost) a mix n match approach, you can use whichever
API call is easier for you, OS or OpenGL native and interleave them.
There are some issues that arise but I don't do enough graphics
work to fully understand them! For my simple needs it all pretty
much just worked.

PS.
When I write MacOS above I suspect I should really be saying
Cocoa, but I'm, not even expert enough in MacOSX to be sure of
that! :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Fw: URGENT: PYTHON QUESTION

2016-03-31 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
This is working fine. What is the problem?


def manipulate_data(kind, data):
if kind == 'list':
return list(data)[::-1]
elif kind == 'set':
#data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
return set(data)
elif kind == 'dictionary':
return dict.keys(data)
print manipulate_data("list", range(1,6))
print manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA",
"TIA",  "AFRICA"})
print manipulate_data("dictionary", {"apples": 23, "oranges": 15,
"mangoes": 3, "grapes": 45})
regards,
Sarma.


On Thu, Mar 31, 2016 at 10:15 PM, Steven D'Aprano  wrote:
> On Thu, Mar 31, 2016 at 12:47:21PM +, accessmuah via Tutor wrote:
>> Hi,
>> Pls, assist with this QuestionKindly stroll to the end
>
>> DS LABCreate a function manipulate_data that does the followingAccepts
>> as the first parameter a string specifying the data structure to be
>> used "list", "set" or "dictionary" Accepts as the second parameter the
>> data to be manipulated based on the data structure specified e.g [1,
>> 4, 9, 16, 25] for a list data structure Based off the first parameter
>>- return the reverse of a list or
>>- add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
>> resulting set
>>- return the keys of a dictionary
>>
>>
>> My Answer below - Kindly helped reviewed it
>> def manipulate_data(kind, data): if kind == 'list': return
>> list(data)[::-1] elif kind == 'set': data=set({"a", "b",
>> "c", "d", "e", "ANDELA", "TIA", "AFRICA"})return set(data)
>> elif kind == 'dictionary': return
>> dict.keys(data) manipulate_data("list",
>> range(1,6)) manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA",
>> "TIA", "AFRICA"})manipulate_data("dictionary", {"apples": 23,
>> "oranges": 15, "mangoes": 3, "grapes": 45})
>
> Unfortunately your code has been mangled by the email. Can you try
> sending it again WITHOUT using Yahoo's "Rich Text" (HTML mail)?
>
> I will try to reverse-engineer what you meant:
>
> def manipulate_data(kind, data):
> if kind == 'list':
> return list(data)[::-1]
> elif kind == 'set':
> data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
> return set(data)
> elif kind == 'dictionary':
> return dict.keys(data)
>
> manipulate_data("list", range(1,6))
> manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
> manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
> "grapes": 45})
>
>
> Is that what you intended?
>
>
>
>> CODE RESULT
>>
>>
>>  But i cant proceed to next stage...see error below   Pls assist
>
> I looked below, but you have not included the error. Perhaps you
> included it as an attachment? In that case, it would probably be
> deleted, and if it is a screen-shot, it will be useless to anyone who is
> blind or visually impaired and reading this using a screen reader.
>
> Please COPY and PASTE the text of the error into your email.
>
>
>
>
>
>
>>
>>
>>
>> Thanks
>> Regards
>> Shittu
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor