Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106511
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Promoting Python |
| Date | 2016-04-05 08:13 -0400 |
| Organization | IISS Elusive Unicorn |
| Message-ID | <mailman.65.1459858471.32530.python-list@python.org> (permalink) |
| References | <DUB110-DS131649FA6F6AA56BBDD63E989E0@phx.gbl> <mailman.54.1459840979.32530.python-list@python.org> <dfada2fa-39b9-4d89-a47c-c4e0742be9e0@googlegroups.com> <8297gblfu46c3p57sbu5i5h2lprsrl29u5@4ax.com> |
On Tue, 5 Apr 2016 00:31:10 -0700 (PDT), Rustom Mody
<rustompmody@gmail.com> declaimed the following:
>> Liberty Basic
>> for n = 32 to 255: print n;chr$(n) : next n
>
>I grew up on BBC basic in 1984. Not used thereafter.
>
>Your first one is (I guess) this in python:
>
>>>> for i in range(32,127):
>... print chr(i),
>...
> ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
>
Not quite...
>>> for i in range(32, 256):
... print i, chr(i)
...
32
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
45 -
...
Though characters 128-255 may depend on the computer encoding...
PythonWin console gives:
244 ??5 ??6 ??7 ??8 ??9 ??0 ??1 ??2 ??3 ??4 ??5 ??>
(actually -- it displays inverse video blue HEX values...)
Windows command shell is something like
244 (
245 )
246 ÷
247 ˜
248 °
249 ·
250 ·
251 v
252 n
253 ²
254 ¦
255
>>>
Though the first two are not parentheses, but make up an integral sign,
247 is a double-tilde, 251 is a square root. Apparently Forte Agent has a
different encoding than the Windows command shell.
>>
>> REM BBC Basic
>> FOR c = 1 TO 15 : COLOUR c
>> PRINT "Color ";c
>> NEXT c
>>
>> REM BBC Basic
>> c = 0
>> FOR x = 80 TO 2000 STEP 96
>> GCOL c: CIRCLE FILL x,500,50 : c = c + 1
>> NEXT x
>
>If you tell us some more of what color, gcol etc do someone will likely show you
>Though in all fairness I dont expect it to be as pithy as the BASIC
Off hand, I'd guess "colour" sets text output color, "gcol" likely sets
graphics color, and "circle fill" likely draws a filled circle in that
color.
For the OP: Very few languages have built-in graphics commands; which
is why porting BASIC programs was so difficult. This means you have to
import some graphical framework and use ITS command functions.
Unfortunately, there are so many routes... If you are on Windows, and
install the win32 python extension, you can make use of the native Win32
libraries to create device contexts, draw into them, etc. Be ready to drown
in the less than clear MSDN documentation. For example, this might be the
"circle fill" (once you've defined the context/window, pen, and brush
https://msdn.microsoft.com/en-us/library/vs/alm/dd162510%28v=vs.85%29.aspx
Or, since Python includes an interface to Tk, there is a "turtle
graphics" module that may be usable (it will be more portable than Win32).
>From the 2.7 help system ( https://docs.python.org/2/library/turtle.html or
https://docs.python.org/3/library/turtle.html depending on version of
Python installed):
-=-=-=-=-
Turtle graphics is a popular way for introducing programming to kids. It
was part of the original Logo programming language developed by Wally
Feurzig and Seymour Papert in 1966.
Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an
import turtle, give it the command turtle.forward(15), and it moves
(on-screen!) 15 pixels in the direction it is facing, drawing a line as it
moves. Give it the command turtle.right(25), and it rotates in-place 25
degrees clockwise.
By combining together these and similar commands, intricate shapes and
pictures can easily be drawn.
The turtle module is an extended reimplementation of the same-named module
from the Python standard distribution up to version Python 2.5.
It tries to keep the merits of the old turtle module and to be (nearly)
100% compatible with it. This means in the first place to enable the
learning programmer to use all the commands, classes and methods
interactively when using the module from within IDLE run with the -n
switch.
The turtle module provides turtle graphics primitives, in both
object-oriented and procedure-oriented ways. Because it uses Tkinter for
the underlying graphics, it needs a version of Python installed with Tk
support.
-=-=-=-=-
turtle.circle(radius, extent=None, steps=None)
Parameters: radius – a number
extent – a number (or None)
steps – an integer (or None)
Draw a circle with given radius. The center is radius units left of the
turtle; extent – an angle – determines which part of the circle is drawn.
If extent is not given, draw the entire circle. If extent is not a full
circle, one endpoint of the arc is the current pen position. Draw the arc
in counterclockwise direction if radius is positive, otherwise in clockwise
direction. Finally the direction of the turtle is changed by the amount of
extent.
-=-=-=-=-
turtle.fill(flag)
Parameters: flag – True/False (or 1/0 respectively)
Call fill(True) before drawing the shape you want to fill, and fill(False)
when done. When used without argument: return fillstate (True if filling,
False else).
-=-=-=-=-
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Promoting Python "Gordon( Hotmail )" <sionet3344@hotmail.co.uk> - 2016-04-05 06:48 +0100
Re: Promoting Python Rustom Mody <rustompmody@gmail.com> - 2016-04-05 00:31 -0700
Re: Promoting Python Joel Goldstick <joel.goldstick@gmail.com> - 2016-04-05 08:06 -0400
Re: Promoting Python alister <alister.ware@ntlworld.com> - 2016-04-05 18:02 +0000
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-05 19:47 +0100
Re: Promoting Python alister <alister.ware@ntlworld.com> - 2016-04-05 19:38 +0000
Re: Promoting Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-05 08:13 -0400
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-05 15:31 +0300
Re: Promoting Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-06 20:52 +1200
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 12:12 +0300
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-06 12:06 +0100
Re: Promoting Python Ned Batchelder <ned@nedbatchelder.com> - 2016-04-06 04:38 -0700
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-06 14:21 +0100
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 14:46 +0300
Re: Promoting Python Michael Selik <michael.selik@gmail.com> - 2016-04-06 13:33 +0000
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 17:14 +0300
Re: Promoting Python Chris Angelico <rosuav@gmail.com> - 2016-04-07 00:20 +1000
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 21:23 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 21:50 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 22:30 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 22:22 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 22:59 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 23:39 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-07 01:03 +0300
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-07 09:30 +0300
Re: Promoting Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-07 00:56 -0600
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-07 10:19 +0300
Re: Promoting Python Steven D'Aprano <steve@pearwood.info> - 2016-04-08 16:09 +1000
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 23:05 +0300
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-06 14:54 +0100
Re: Promoting Python Marko Rauhamaa <marko@pacujo.net> - 2016-04-06 17:08 +0300
Re: Promoting Python Larry Martell <larry.martell@gmail.com> - 2016-04-06 10:36 -0400
Re: Promoting Python Chris Angelico <rosuav@gmail.com> - 2016-04-07 00:14 +1000
Re: Promoting Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-06 15:20 +0100
Re: Promoting Python Ned Batchelder <ned@nedbatchelder.com> - 2016-04-06 07:34 -0700
Re: Promoting Python Ned Batchelder <ned@nedbatchelder.com> - 2016-04-06 10:55 -0700
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-06 23:24 +0100
Re: Promoting Python BartC <bc@freeuk.com> - 2016-04-06 18:04 +0100
Re: Promoting Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-06 08:04 -0400
Re: Promoting Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-06 13:39 +0100
Re: Promoting Python Steven D'Aprano <steve@pearwood.info> - 2016-04-07 03:40 +1000
csiph-web