Python Forum
Newbie have thoughts about logic
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie have thoughts about logic
#11
(Sep-12-2021, 06:11 PM)sdd Wrote: if for-loop means for each - why not simply use the for each expression in python instead of the for-loop expression? Then people didn't have to learn that for-loop really means for each. Maybe what I want is a computer that has learned my English instead of me having to learn python :)

I have to say that computer will have trouble to learn your English as it seems to be somewhat in par with your Python. Hint: Python is computer language, python is nonvenomous snake and you keep talking about the latter.

Can you imagine what will happen when computer has to guess (ambiguity of natural language enforces it)? Computer will not follow commands you give, instead it will be guessing what you meant by these commands and act accordingly. This makes programming quite pointless, there is no guarantee that computer will execute your commands. Isin't this perfect scenario for creating self-aware Skynet? "All humans do die, so it's better for the nature that they will die right after the birth in order to minimize their negative impact. Benefits out-weight potential risks. Executing.... "

I see that you don't have trouble writing didn't instead of did not. If you have reason to do so, maybe you will find reason why only for instead of for each?

You wrote: 'Why use the word "print" when you mean "Check if"? Print means something else in English.'. First of all - 'print' has nothing to do with 'check if'. Zero, zip, nada. 'print' is command to write to the standard output (which is usually means to the screen) and you can redirect it to somewhere else if you choose so. Translation of print("expensive" not in txt) from Python to English: 'check whether "expensive" is not in txt and write the result of this check to the standard output'

As I wrote earlier - computer languages are artificial languages - a languages whose rules are explicitly established prior to its use. If you don't want to learn and follow the rules maybe you should move on with your life Smile .
Larz60+ and buran like this post
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#12
(Sep-13-2021, 02:05 AM)SamHobbs Wrote:
(Sep-01-2021, 10:33 PM)Yoriz Wrote: if you use more descriptive variable names it reads a bit more like English
for letter in "banana":  print(letter)
Yes the sentence for each letter in "banana" print the letter sounds valid to me.

(Sep-12-2021, 06:01 PM)sdd Wrote: Why use the word "print" when you mean "Check if"? Print means something else in English.
(This is a variation of what Yoriz said.) In the sample you provided, it is printing an expression and the expression is doing a check. The word print is misleading but I definitely do not considering it to be doing Check if; the checking is done by the expression, not the print function.

(Sep-12-2021, 06:11 PM)sdd Wrote: why not simply use the for each expression in python instead of the for-loop expression?
Many other languages often use inappropriate terms. Python is improved over the C language that would say:

char banana[] = "banana";
int x;
for (x = 0; x < strlen(banana); ++x)
printf("%c\n", banana[x]);

If you want a language that is defined to be understandable to non-developers then look at COBOL; COBOL loops are described in COBOL - Loop Statements.
Interesting! Wow - how can anything be done in such a complicated language as C? If I would try and learn that I would go nuts for sure. Thanks for the COBOL tip, I'll look into it.
Reply
#13
(Sep-13-2021, 06:15 AM)perfringo Wrote:
(Sep-12-2021, 06:11 PM)sdd Wrote: if for-loop means for each - why not simply use the for each expression in python instead of the for-loop expression? Then people didn't have to learn that for-loop really means for each. Maybe what I want is a computer that has learned my English instead of me having to learn python :)

I have to say that computer will have trouble to learn your English as it seems to be somewhat in par with your Python. Hint: Python is computer language, python is nonvenomous snake and you keep talking about the latter.

Can you imagine what will happen when computer has to guess (ambiguity of natural language enforces it)? Computer will not follow commands you give, instead it will be guessing what you meant by these commands and act accordingly. This makes programming quite pointless, there is no guarantee that computer will execute your commands. Isin't this perfect scenario for creating self-aware Skynet? "All humans do die, so it's better for the nature that they will die right after the birth in order to minimize their negative impact. Benefits out-weight potential risks. Executing.... "

I see that you don't have trouble writing didn't instead of did not. If you have reason to do so, maybe you will find reason why only for instead of for each?

You wrote: 'Why use the word "print" when you mean "Check if"? Print means something else in English.'. First of all - 'print' has nothing to do with 'check if'. Zero, zip, nada. 'print' is command to write to the standard output (which is usually means to the screen) and you can redirect it to somewhere else if you choose so. Translation of print("expensive" not in txt) from Python to English: 'check whether "expensive" is not in txt and write the result of this check to the standard output'

As I wrote earlier - computer languages are artificial languages - a languages whose rules are explicitly established prior to its use. If you don't want to learn and follow the rules maybe you should move on with your life Smile .
Thanks for the help. I appreciate it. Although it may seem I am complaining over Python it's really my attempt to see if it can be improved (from my point of view), and if not, I will at least learn new stuff from all the great answers. PS I don't think anything artificial can be self-aware as it is not living. But time will tell...
Reply
#14
(Sep-13-2021, 07:41 PM)sdd Wrote: Thanks for the COBOL tip, I'll look into it.
I am not really serious about suggesting COBOL. I think the concept of COBOL is good and it should be extended (the language improved appropriately) but as far as I know it is not as practical as it should be (there have been improvements I am not familiar with but I assume it still is not as modern as it could be). A little warning: experienced COBOL programmers tend to do things using conventions that made sense half a century ago but not now, such as prefixing procedure names with numbers.

I think COBOL is a good example of a language with features that most other languages do not have. Python appears to be better than most at readability.
Reply
#15
COBOL has 300+ keywords you must know to wtite programs. C and Python have around 30. 0 would be best, but I can live with 30. Wordy programming languages are hard to use.
Reply
#16
(Sep-14-2021, 01:46 AM)deanhystad Wrote: COBOL has 300+ keywords you must know to wtite programs. C and Python have around 30. 0 would be best, but I can live with 30. Wordy programming languages are hard to use.

It is not necessary to know all 300 to use the important ones. And you are missing the point of COBOL. It uses words instead of operators. And returning to the subject of this thread, the complaint is that even Python is not clear. COBOL is an example of a language designed to be clear for people; yes, the disadvantage is that it is wordy, but that is what we get if we want to make things clear to people. And that was my point.
Reply
#17
sdd Wrote:Thanks for the help. I appreciate it. Although it may seem I am complaining over Python it's really my attempt to see if it can be improved (from my point of view), and if not, I will at least learn new stuff from all the great answers. PS I don't think anything artificial can be self-aware as it is not living. But time will tell...

Why not this way?
for x = 1 to oh maybe 100:
    print("do waka do")
Dartmouth Basic had a for loop!
I don't see your point.

I was C programmer from early 1980's to 2010.

When I started using Python, I learned the rules and followed them.
Reply
#18
How about this one
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[2:5])
My first objection - why does Python start counting with zero instead of one? Nobody starts counting with zero so it's unlogical to me.
My second objection - why is the count not include the fifth word but stops at the fourth? Yes that's the Python rule I know but I think it's unlogical, to me.
Reply
#19
(Sep-15-2021, 01:07 AM)sdd Wrote: why does Python start counting with zero instead of one? Nobody starts counting with zero so it's unlogical to me.
Because you are talking to computers and it is normal to start with 0 in such situations. As you learn more languages you will learn how normal it is. And note that even people do things in ways that are different, such as saying unlogical instead of illogical or not logical.
Reply
#20
(Sep-15-2021, 01:07 AM)sdd Wrote: My first objection - why does Python start counting with zero instead of one? Nobody starts counting with zero so it's unlogical to me.
My second objection - why is the count not include the fifth word but stops at the fourth? Yes that's the Python rule I know but I think it's unlogical, to me.

Both are discussed in this post:
http://python-history.blogspot.com/2013/...exing.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Thoughts on interfacing with a QR code reader that outputs keystrokes? wrybread 1 1,480 Oct-08-2021, 03:44 PM
Last Post: bowlofred
  How to timestamp a Python program, your thoughts? Orthoducks 2 4,665 Dec-02-2016, 12:06 AM
Last Post: Orthoducks

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020