Unofficial Programming Thread IV

Post » Tue Jun 18, 2013 9:18 am

Just started with C++ (despite all of you saying otherwise....) recently, and I'm enjoying it /biggrin.png' class='bbc_emoticon' alt=':D' /> Although, I'm putting it off for a few weeks as I have exams and the likes to focus on.
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Tue Jun 18, 2013 2:39 am

Finally got my script done and it works well. I did also build in an answer command since it is a practice application for subnetting. I am using input() to get the user input until it is correct. I can't seem to find a way to just repeat the line if its wrong. Right now when wrong the user will get output like http://i.imgur.com/lze09.png, with the amount oflines based on how many invalid input attempts there were. I am hoping to keep the input to a single line per question and tried to just put a \r at the start of the string but that did not seem to help. Any ideas?
User avatar
Curveballs On Phoenix
 
Posts: 3365
Joined: Sun Jul 01, 2007 4:43 am

Post » Tue Jun 18, 2013 1:43 pm


You'll probably need to get into cursor positioning if you want to do that. Using C/Unix the usual approach would be to use the curses package, but I've absolutely no idea about Python on Windows; I'd suggest just keeping it simple, print a line saying "invalid input" or whatever and starting a new line asking for it again. Unless there's a quick and easy forms package available, you'll spend more of your time trying to make it look good than its basic functionality! If you really wanted to do it the way you're talking about, another possibility is to write your own input routine so it doesn't print the newline afterwards, but that's still going to potentially be more code than you want to get involved with.

That's with the caveat that Python may yet have some quick and easy means of doing what you want: I don't know the language at all and I'm just writing in very general terms.
User avatar
Lauren Graves
 
Posts: 3343
Joined: Fri Aug 04, 2006 6:03 pm

Post » Tue Jun 18, 2013 4:20 am

http://www.geekwire.com/2012/coding-fun-microsofts-visual-studio-badges-leaderboard

This is awesome (As long as this stays an extension and not a native feature.)
User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Tue Jun 18, 2013 6:14 am

I managed to use cx_freeze on the script I finally finished but it only works if I run it on the script itself. If I use a setup.py to set file attributes such as author and description, it does not work as it tell me that it cannot find a a__main__ in my script when it does have a check for it using __name__ and it runs fine. I am confused why the setup.py would break it but when running cx_freeze on the script itself works.

However the above is such a minor issue and I did enjoy using Python for this project. Was a good project to start learning it as well as some weird math that I needed to do. Definately plan to continueto learn Python in the future, as well as C# still.
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Tue Jun 18, 2013 1:54 am

1842 - Ada Lovelace writes the first program. She is hampered in her efforts by the minor inconvenience that she doesn't have any actual computers to run her code. Enterprise architects will later relearn her techniques in order to program in UML.

1936 - Alonzo Church also invents every language that will ever be but does it better. His lambda calculus is ignored because it is insufficiently C-like. This criticism occurs in spite of the fact that C has not yet been invented.


1964 - John Kemeny and Thomas Kurtz create BASIC, an unstructured programming language for non-computer scientists.

1965 - Kemeny and Kurtz go to 1964.


1970 - Niklaus Wirth creates Pascal, a procedural language. Critics immediately denounce Pascal because it uses "x := x + y" syntax instead of the more familiar C-like "x = x + y". This criticism happens in spite of the fact that C has not yet been invented.

1972 - Dennis Ritchie invents a powerful gun that shoots both forward and backward simultaneously. Not satisfied with the number of deaths and permanent maimings from that invention he invents C and Unix.

1980 - Alan Kay creates Smalltalk and invents the term "object oriented." When asked what that means he replies, "Smalltalk programs are just objects." When asked what objects are made of he replies, "objects." When asked again he says "look, it's all objects all the way down. Until you reach turtles."


1983 - Bjarne Stroustrup bolts everything he's ever heard of onto C to create C++. The resulting language is so complex that programs must be sent to the future to be compiled by the Skynet artificial intelligence. Build times suffer. Skynet's motives for performing the service remain unclear but spokespeople from the future say "there is nothing to be concerned about, baby," in an Austrian accented monotones. There is some speculation that Skynet is nothing more than a pretentious buffer overrun.

1986 - Brad Cox and Tom Love create Objective-C, announcing "this language has all the memory safety of C combined with all the blazing speed of Smalltalk." Modern historians suspect the two were dyslexic.

1987 - Larry Wall falls asleep and hits Larry Wall's forehead on the keyboard. Upon waking Larry Wall decides that the string of characters on Larry Wall's monitor isn't random but an example program in a programming language that God wants His prophet, Larry Wall, to design. Perl is born.

2003 - A drunken Martin Odersky sees a Reese's Peanut Butter Cup ad featuring somebody's peanut butter getting on somebody else's chocolate and has an idea. He creates Scala, a language that unifies constructs from both object oriented and functional languages. This pisses off both groups and each promptly declares jihad.
User avatar
Tinkerbells
 
Posts: 3432
Joined: Sat Jun 24, 2006 10:22 pm

Post » Tue Jun 18, 2013 12:50 am


/laugh.png' class='bbc_emoticon' alt=':laugh:' /> If that isn't what actually happened, it should've been!
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Tue Jun 18, 2013 7:42 am

/tongue.png' class='bbc_emoticon' alt=':P' /> the full story is here http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Tue Jun 18, 2013 4:20 pm

If they're not defined with 'self' they're not class variables. 'self' is used in anything you want, for lack the most accurate term possible, globally accessible in your class. Go ahead and make a function in a Python class and leave out the self parameter. It won't run.
User avatar
Dalton Greynolds
 
Posts: 3476
Joined: Thu Oct 18, 2007 5:12 pm

Post » Tue Jun 18, 2013 12:48 am



I just wish to point out that Wadler is the most awesome lecturer http://www.youtube.com/watch?v=5TMojC0Nb6A.
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Post » Tue Jun 18, 2013 9:53 am

Uh. http://ideone.com/rG7wm? If they are defined on an instance (i.e. with self) they are instance variables (and not class variables) because they are not defined for all instances of the class.

Go read the http://docs.python.org/tutorial/classes.html, specifically Class Objects and Instance Objects.
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm

Post » Tue Jun 18, 2013 5:11 am

The more you know. Maybe a more formal education in Python would have saved me the misconception. I've been using instanced objects since I started. /confused.gif' class='bbc_emoticon' alt=':confused:' />

Edit: But just to give an example of how out-of-whack my learning in programming has been, I didn't know what header files were until I'd already written my first game. How I managed to do so still baffles me.
User avatar
oliver klosoff
 
Posts: 3436
Joined: Sun Nov 25, 2007 1:02 am

Post » Tue Jun 18, 2013 7:58 am

I finally figured out how to cx_freeze a set of Python scripts using a setup.py file and give it a version number and other fun stuff. I had to make a change to one module, hopefully correct context of that word, for my program since it consists of two files and I was thinking of incrementing a version number of the file but then when it came to my changelog not sure how to document that it was that file I made a change in. So I ended up taking version numbers from both files and then just having one overall version number with its changes listed. What might you guys recommend I do in this situation?
User avatar
Nauty
 
Posts: 3410
Joined: Wed Jan 24, 2007 6:58 pm

Post » Tue Jun 18, 2013 1:49 am

Java Question : http://i1233.photobucket.com/albums/ff398/Papafern1/JavaQuestion.jpg

Can anyone tell me how those answer relate to the question because I assumed it would be 6.
I'm supposed to practise this MTA but it's [censored] that half the stuff in it has never been cover via the course we done.

EDIT: Never mind I wasn't reading the script correctly.
Spoiler
Answer is 166
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Tue Jun 18, 2013 9:56 am

...Javascript. Not Java. There's a difference /tongue.png' class='bbc_emoticon' alt=':P' />

And yeah, the script prints myValue thrice: once before it's changed in multiply, and twice after.
User avatar
Charles Weber
 
Posts: 3447
Joined: Wed Aug 08, 2007 5:14 pm

Post » Tue Jun 18, 2013 11:06 am

Yeah I noticed the .write and was kicking myself for sitting there like an idiot thinking it was 6, these exams are gonna kill me mentally...
User avatar
GPMG
 
Posts: 3507
Joined: Sat Sep 15, 2007 10:55 am

Post » Tue Jun 18, 2013 2:01 pm

Java is to JavaScript as cars are to carpets
User avatar
Ian White
 
Posts: 3476
Joined: Thu Jul 19, 2007 8:08 pm

Post » Tue Jun 18, 2013 4:00 am

*writes down for future reference*
User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm

Post » Tue Jun 18, 2013 3:08 am

I really wouldn't know the difference, I've never had live contact with either of them - yet I'm meant to know this stuff /dry.png' class='bbc_emoticon' alt='<_<' />
User avatar
CHANONE
 
Posts: 3377
Joined: Fri Mar 30, 2007 10:04 am

Post » Tue Jun 18, 2013 1:21 pm

Java's a general purpose, object-oriented programming language whereas Javascript is a scripting language (also object-oriented, I think) used in browsers and stuffs.

Both are decently useful languages to know.
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Tue Jun 18, 2013 7:54 am

Java's just a fad, it'll never catch on. I've been saying that for 15 years and people still don't believe me! /hehe.gif' class='bbc_emoticon' alt=':hehe:' />
User avatar
NIloufar Emporio
 
Posts: 3366
Joined: Tue Dec 19, 2006 6:18 pm

Post » Tue Jun 18, 2013 6:37 am

My course is primarily based on C#, nothing else, and I have been doing work experience which involves VB - These are the only languages I've came across to have at least some knowledge of (HTML as well).
But these exams (Software development fundamentals and Web development fundamentals) have nearly nothing of what I've learnt in them, and they are randomly generated from a 115 question bank which I think is complete [censored] because it doesn't give a fair exam.
Like me and the other apprentice - I failed by 1 mark and he passed by 1, had I got 3 of the questions he mentioned I would have passed, its messed up.
User avatar
Annick Charron
 
Posts: 3367
Joined: Fri Dec 29, 2006 3:03 pm

Post » Tue Jun 18, 2013 2:19 pm

For those of you know who multiple languages how do you choose which you use on a particular project? Right now I know a bit of C#, or enough to figure out what I need to look at and to find examples online to learn from, and in the process of learning Python 3. At the moment I choose based on if I want a GUI (I do C#) or if I want it to run on Linux (Python 3), but not sure beyond that. Some projects I thinkof are fine in a console for me but a GUI owuld be helpful, just not required, so I get stuck with the choice.
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Tue Jun 18, 2013 9:03 am

I don't do any coding in my spare time, though I want to look at modding games.
I let my work choose for me, depending on what prject I'm given I might be working with C# or VB, maybe even C++ though I know nothing about it and would likely have a shadowing job.
User avatar
Albert Wesker
 
Posts: 3499
Joined: Fri May 11, 2007 11:17 pm

Post » Tue Jun 18, 2013 5:31 am

Has anyone else tried googling recursion? I was really amused...
User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am

PreviousNext

Return to Othor Games