What is this? Not a string.. - Page 3 - Overclock.net - An Overclocking Community

Forum Jump: 

What is this? Not a string..

Reply
 
Thread Tools
post #21 of 44 (permalink) Old 10-25-2018, 01:52 PM
New to Overclock.net
 
deepor's Avatar
 
Join Date: Feb 2013
Posts: 4,736
Rep: 474 (Unique: 320)
I have a feeling what normal people think of "math" isn't important at all for programming. There is another math that's weird and abstract and about logic and not really useful for anything and that one might train the brain for programming, but you won't run into that kind of math in beginner courses. I bet it's best to just practice programming directly, without going through the math route.
deepor is offline  
Sponsored Links
Advertisement
 
post #22 of 44 (permalink) Old 10-25-2018, 02:49 PM
New to Overclock.net
 
xToaDx's Avatar
 
Join Date: Jul 2008
Posts: 3,015
Rep: 276 (Unique: 225)
Quote: Originally Posted by deepor View Post
I have a feeling what normal people think of "math" isn't important at all for programming. There is another math that's weird and abstract and about logic and not really useful for anything and that one might train the brain for programming, but you won't run into that kind of math in beginner courses. I bet it's best to just practice programming directly, without going through the math route.
You are probably right. My experience with programming is strictly related to engineering. So any programming I have done is fairly math intensive.

I’m sure there are plenty of programming applications that are not math heavy, but I truly believe that the more math you know, the more you will be able to do with software.

But I’m not sure why you say logic is not useful. Knowing if something is true (1) or false (0) is extremely useful.

In my experience, the guys that say math is unimportant are always the guys who are scared of math.

xToaDx is offline  
post #23 of 44 (permalink) Old 10-25-2018, 03:56 PM
New to Overclock.net
 
deepor's Avatar
 
Join Date: Feb 2013
Posts: 4,736
Rep: 474 (Unique: 320)
I was exaggerating earlier. If your brain is trained to deal with that type of math that's about logic, that helps to also deal with programming so in that sense it's great.

I tried to find a random example of what I was joking about. There's something called a "quantale" in "linear logic". This here is the introduction for it on Wikipedia:

"In mathematics, quantales are certain partially ordered algebraic structures that generalize locales (point free topologies) as well as various multiplicative lattices of ideals from ring theory and functional analysis (C*-algebras, von Neumann algebras). Quantales are sometimes referred to as complete residuated semigroups."

It's like this is on a different planet than the type of math from high-school and what a beginner's course is about.
deepor is offline  
Sponsored Links
Advertisement
 
post #24 of 44 (permalink) Old 10-26-2018, 02:02 AM
New to Overclock.net
 
ltpdttcdft's Avatar
 
Join Date: Jun 2013
Posts: 587
Rep: 36 (Unique: 30)
Wikipedia math articles are often written incomprehensibly. If you find yourself stuck on Wikipedia while researching something math-related you're probably better off doing another web search for the subject and clicking on some results other than Wikipedia.



ltpdttcdft is offline  
post #25 of 44 (permalink) Old 10-26-2018, 02:56 AM
Overclocker
 
JackCY's Avatar
 
Join Date: Jun 2014
Posts: 10,008
Rep: 339 (Unique: 240)
Simple, what's the problem really, might need to take a different class before Python, one about math and logic.

Quote:
2 ** 3 == 108 % 100 or 'Cleese' == 'King Arthur'
2 ** 3 or also written as 2^3 is 2*2*2 = 8
108 % 100 or also written as 108 mod 100, 108 modulo 100 is 108 % 100 = 8, aka remove 100 as many times as it fits

8 == 8, "8 equals? 8" True

"'Cleese' equals? 'King Arthur'" False

True OR False is True

Done.

I think a python guide/documentation shows all this. Try this guide: https://www.learnpython.org/en/Basic_Operators


Wikipedia math articles are often written as they should be, as in fairly top level math not the annoyingly oversimplified elementary/high school kind of math. I'm not saying it's easy to read but there is a reason it's written that way because it can express all the nuances and cases and everyone uses that. Of course it doesn't have to be written and explained incomprehensibly, that's true, even using the harder to read math for common people it can be explained sensibly. Personally I was happy when the oversimplified below University level math was gone, sure deciphering some of the math at high University level is difficult but then it's a difficult math too and most people won't even see it in their whole life.

Last edited by JackCY; 10-26-2018 at 03:01 AM.
JackCY is offline  
post #26 of 44 (permalink) Old 10-31-2018, 10:31 AM - Thread Starter
New to Overclock.net
 
PhotonFanatic's Avatar
 
Join Date: Dec 2009
Posts: 1,878
Rep: 19 (Unique: 18)
I was more wondering how a string could equal a number, not really about the math itself. My question would be something like: How does 4 == "Cheeseburger". Now you can say that you've got 4 cheeseburgers, but I was thinking that to say that you should be using a variable. cheeseburger = 4. You gotta remember I'm brand new to this, I have only finished 30% of an online course. Advanced mathematics don't really enter into it at this point.

Not that I'm bad at math, I've always felt like I was pretty good at it. I'm way out of practice for sure. But I may take some math classes and logic if I feel the need. Depends on what I run into on the job, once I'm done with code academy, have taken the python course/s at the local college, and have gotten certified. Then I'll look at what other improvements can be made to make me a top tier programmer.

Although I will say, that most of the old hand programmers I've talked to (when determining if I wanted to learn) mirror deepor on this. The general sentiment seems to be, that yeah its helpful but not some kind of big deal.

"Executing execution.exe"
Bang for the buck
(12 items)
CPU
3570k @ 4.6Ghz @1.35v
Motherboard
Gigabyte Z77x UD3H
GPU
evga GTX 970 SSC
RAM
16Gb Gskill Ripjaws 2133Mhz @ 9-11-10-28
Hard Drive
Samsung Evo 850
Power Supply
Silverstone 900 watt
Cooling
Thermalright Ultra 120 Extreme
Case
Silverstone Raven (1st edition)
Operating System
Windows 10 Spy Delux
Monitor
Xstar 27" PLS 1440p
Keyboard
Wireless ergonomic
Mouse
Logisys Wireless trackball
▲ hide details ▲
PhotonFanatic is offline  
post #27 of 44 (permalink) Old 11-01-2018, 06:38 PM
New001
 
Join Date: Feb 2016
Posts: 2,668
Quote: Originally Posted by PhotonFanatic View Post
I was more wondering how a string could equal a number, not really about the math itself. My question would be something like: How does 4 == "Cheeseburger". Now you can say that you've got 4 cheeseburgers, but I was thinking that to say that you should be using a variable. cheeseburger = 4. You gotta remember I'm brand new to this, I have only finished 30% of an online course. Advanced mathematics don't really enter into it at this point.

Not that I'm bad at math, I've always felt like I was pretty good at it. I'm way out of practice for sure. But I may take some math classes and logic if I feel the need. Depends on what I run into on the job, once I'm done with code academy, have taken the python course/s at the local college, and have gotten certified. Then I'll look at what other improvements can be made to make me a top tier programmer.

Although I will say, that most of the old hand programmers I've talked to (when determining if I wanted to learn) mirror deepor on this. The general sentiment seems to be, that yeah its helpful but not some kind of big deal.
Anything can equal anything depending on how they are compared. A string is a combination of chars. A char has an int value. Therefore each letter has a numeric value and a string can have a numeric value.
spinFX is offline  
post #28 of 44 (permalink) Old 11-01-2018, 11:35 PM
RIP OCN
 
Join Date: Dec 2014
Posts: 599
Rep: 25 (Unique: 19)
In java "Cheesebuger" = 1236 (added char values together)
C = 67
h = 104
e = 101
e = 101
s = 115
e = 101
b = 98
u = 117
r = 114
g = 103
e = 101
r = 114

Code:
        char[] ca = "Cheeseburger".toCharArray();

        int i = 0;
        for (char cc : ca) {
            i = i + (int) cc;
        }
        
        System.out.println(i);
anti-clockwize is offline  
post #29 of 44 (permalink) Old 11-04-2018, 08:39 AM - Thread Starter
New to Overclock.net
 
PhotonFanatic's Avatar
 
Join Date: Dec 2009
Posts: 1,878
Rep: 19 (Unique: 18)
Quote: Originally Posted by spinFX View Post
Anything can equal anything depending on how they are compared. A string is a combination of chars. A char has an int value. Therefore each letter has a numeric value and a string can have a numeric value.
Ah thank you I didn't think of it that way. Is the numeric value the same as the index? So the numeric value of each character in "Cheeseburger" would correspond to the index. Or are there other numbers assigned to each character somehow? I guess that wouldn't really work. It would get confused when you have more than one of the same letter. I have never seen these numbers which are assigned to strings. Anti_clockwise posted them but where are they actually located? Some module in python they are being drawn from?

And here is another question for today. I don't get where animal came from, as opposed to animals. To me, animal seems to appear out of nowhere. It was never assigned anything.


Code:
animals = ["cat", "ant", "bat"]
animals.sort()

for animal in animals:
  print animal

"Executing execution.exe"
Bang for the buck
(12 items)
CPU
3570k @ 4.6Ghz @1.35v
Motherboard
Gigabyte Z77x UD3H
GPU
evga GTX 970 SSC
RAM
16Gb Gskill Ripjaws 2133Mhz @ 9-11-10-28
Hard Drive
Samsung Evo 850
Power Supply
Silverstone 900 watt
Cooling
Thermalright Ultra 120 Extreme
Case
Silverstone Raven (1st edition)
Operating System
Windows 10 Spy Delux
Monitor
Xstar 27" PLS 1440p
Keyboard
Wireless ergonomic
Mouse
Logisys Wireless trackball
▲ hide details ▲
PhotonFanatic is offline  
post #30 of 44 (permalink) Old 11-04-2018, 11:28 AM
New to Overclock.net
 
deepor's Avatar
 
Join Date: Feb 2013
Posts: 4,736
Rep: 474 (Unique: 320)
Yeah, that 'animal' is coming out of nowhere. It's starting to exist in the line with the 'for' loop. It's getting assigned values there. To be annoyingly clear about what's happening, this part here:

Code:
for animal in animals:
    print animal
First translates into this:

Code:
for animal in ["ant", "bat", "cat"]:
    print animal
And it then translates into:

Code:
animal = "ant"
print animal

animal = "bat"
print animal

animal = "cat"
print animal
About that thing with the 4 == "cheeseburger" test: the answer for Python is, it will always return False when you compare a number and a string. It does not matter what the values are or the length of the string or whatever. Python's rules are, a number and a string are not the same so it always says False.

In other languages, other things happen. There's languages where you don't get True or False, instead you get an error. The language says you made a mistake trying to compare a number and a string and wants you to change your code before it accepts it.

There's also languages like JavaScript or Perl where it will automatically try to convert the string into a number (or the other way around, the number into a string). In those languages the following happens (this is a JavaScript console prompt):

Code:
js> 4 == "4"
true
js> 4 == "cheeseburger"
false
Here's what Python does, like I mentioned earlier it just always says a number compared to a string is False:

Code:
>>> 4 == "cheeseburger"
False
>>> 4 == "4"
False
deepor is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off