ScoreHero
Home | Forum | Wiki
Inbox [ Login ]Inbox [ Login ]
SearchSearch MemberlistMemberlist
ProfileProfile Log inLog in
The Programming Thread / Project Euler Thread
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 28, 29, 30  Next
 
Post new topic   Reply to topic    ScoreHero Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
Southparkhero  





Joined: 23 Aug 2008
Posts: 3251
Location: Some place in NJ.

PostPosted: Wed Sep 29, 2010 12:48 am    Post subject: Reply with quote

I finally started to learn Python today.

I'm learning how to combine strings with variables, and it seems Python is hating me.

Code:
>>num = 18
>>print("You are") + num


then it gives me this..

Code:
Traceback (most recent call last):
File "<pyshell>, line 1, in <module>
print ("You are") + num
Typeerror: unsupported operand type(s) for +: "NoneType" and "str" 




halp
_________________
sdfadf
Back to top
View user's profile Wiki User Page Send private message
Urisma  





Joined: 04 Aug 2007
Posts: 220
Location: The Woodlands, Texas

PostPosted: Wed Sep 29, 2010 1:22 am    Post subject: Reply with quote

are you on python 2.X or 3.X? If 2.X, print is NOT a function. It would be used like this:

Code:

a = "world"
print "hello" + a

Since you are using parentheses after print, I'm assuming you're on python 3.X. If so, it should look like this:

Code:

a = "world"
print("hello" + a)


print is a function, and get's arguments ("hello", and the variable a). It takes these small strings, puts em together, and prints one big string. In your current implementation, print("you are") is correct, but you're trying to add the string "18" to the end. Python is typeless, however I believe it should look like this (I'm not a python expert)

Code:

num = "18" // num is a string, not a number
print(" you are" + num)


I think that takes care of it. Hope that helps!
Back to top
View user's profile Send private message XBL Gamertag: TuftedToaster
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Wed Sep 29, 2010 1:29 am    Post subject: Reply with quote

I have my first test in my programming class tomorrow. Wish me luck!
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
Southparkhero  





Joined: 23 Aug 2008
Posts: 3251
Location: Some place in NJ.

PostPosted: Wed Sep 29, 2010 1:35 am    Post subject: Reply with quote

Urisma wrote:
are you on python 2.X or 3.X? If 2.X, print is NOT a function. It would be used like this:

Code:

a = "world"
print "hello" + a

Since you are using parentheses after print, I'm assuming you're on python 3.X. If so, it should look like this:

Code:

a = "world"
print("hello" + a)


print is a function, and get's arguments ("hello", and the variable a). It takes these small strings, puts em together, and prints one big string. In your current implementation, print("you are") is correct, but you're trying to add the string "18" to the end. Python is typeless, however I believe it should look like this (I'm not a python expert)

Code:

num = "18" // num is a string, not a number
print(" you are" + num)


I think that takes care of it. Hope that helps!


You're good..

Thanks!

Also I'm on 3.x.

So far, Python is really easy. I'm learning from tutorials by thenewboston on YouTube. I know textbooks are a lot better then tutorials on the internet, but his tutorials for a bunch of programming languages are fantastic.
_________________
sdfadf
Back to top
View user's profile Wiki User Page Send private message
Urisma  





Joined: 04 Aug 2007
Posts: 220
Location: The Woodlands, Texas

PostPosted: Wed Sep 29, 2010 2:19 am    Post subject: Reply with quote

THABEAST721 wrote:
I have my first test in my programming class tomorrow. Wish me luck!


Good luck! What's the material?

and Southparkhero: You're welcome. Happy to help anytime.
Back to top
View user's profile Send private message XBL Gamertag: TuftedToaster
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Wed Sep 29, 2010 3:58 am    Post subject: Reply with quote

Well first of all, we use java. It is basically a mix of syntax (ie what will give a compiler error), solving math expressions in the way that a computer would, and using the math and string library. I think math and string are called classes; I'm not sure, but I know how to use both of them very well, so I feel that I should be fine for this exam.

My professor said it will be in the format of: 90 points total, 15 points being true false, 15 being solving math expressions, 30 being write a java statement which will perform the following task, and 30 being writing a java program to accomplish something. She said we will need to use the modulo operator in the program we have to write, but that is the only hint she gave.

I feel confident though because I know almost everything we have covered.
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
footballtom3685  





Joined: 16 Sep 2007
Posts: 2478
Location: Bay Area, CA

PostPosted: Wed Sep 29, 2010 9:14 am    Post subject: Reply with quote

@THABEAST721: I'd bet money that it'll ask you to do something with primes. Mod is almost always used with primes (in programming exercises at least...and quite often otherwise from what I've done so far). It could also be something with even or odd numbers, but since there's a focus on math I'd bet primes.

Southparkhero wrote:
Urisma wrote:
are you on python 2.X or 3.X? If 2.X, print is NOT a function. It would be used like this:

Code:

a = "world"
print "hello" + a

Since you are using parentheses after print, I'm assuming you're on python 3.X. If so, it should look like this:

Code:

a = "world"
print("hello" + a)


print is a function, and get's arguments ("hello", and the variable a). It takes these small strings, puts em together, and prints one big string. In your current implementation, print("you are") is correct, but you're trying to add the string "18" to the end. Python is typeless, however I believe it should look like this (I'm not a python expert)

Code:

num = "18" // num is a string, not a number
print(" you are" + num)


I think that takes care of it. Hope that helps!


You're good..

Thanks!

Also I'm on 3.x.

So far, Python is really easy. I'm learning from tutorials by thenewboston on YouTube. I know textbooks are a lot better then tutorials on the internet, but his tutorials for a bunch of programming languages are fantastic.
Uhh, Python isn't typeless. The best way to print a string with an int (or float, etc.) is to cast the number to a string:
Code:
num = 36
print("Number: " + str(num))
Output would be "Number: 36"

I'm taking a self-paced python course (read the book and do assignments at your own pace, no lectures/discussions/labs) and the book is available online for free if anyone is interested. In fact, if you really wanted to you could basically take the course (except for quizzes and the final) online as well, all of the assignments are available.

Also taking another self paced class on UNIX, which I think will be very useful to know. Of course there's a lot to know...

And I'm taking a Data Structures course in Java, which I already knew from AP CS, but mostly forgot so this is a nice refresher. So far I haven't really learned anything new though so the class is pretty simple.

Oh...and I'm taking a discrete math course which is technically in the CS department. Probably the coolest class I've taken so far. I really never liked proofs (hated them, mostly) but even with so much of the class so far based on proofs it's been really interesting.

So yeah...I'm doing a bit of programming this semester
Back to top
View user's profile Wiki User Page Send private message Send e-mail
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Wed Sep 29, 2010 4:24 pm    Post subject: Reply with quote

footballtom3685 wrote:


I'm taking a self-paced python course (read the book and do assignments at your own pace, no lectures/discussions/labs) and the book is available online for free if anyone is interested. In fact, if you really wanted to you could basically take the course (except for quizzes and the final) online as well, all of the assignments are available.


Interesting stuff there. I'll have to check it out when I can.
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Wed Sep 29, 2010 10:43 pm    Post subject: Reply with quote

Well my exam was loleasy. I knew the answer to every single question, and writing the program at the end wasn't hard at all.

For the program at the end, we had to prompt the user to enter an amount of elapsed time in seconds, and convert that time to display it in hours, minutes, and seconds. I did something like this:

Code:
import java.util.Scanner;
public class timeConversion {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int userTime;
        int hours, minutes, seconds;
        int temporary;
       
        System.out.print("Enter an amount of time in seconds");

        userTime = sc.nextInt();

        hours = userTime/3600;
        temporary = userTime%3600;
        minutes = temporary/60;
        seconds = minutes%60;

        System.out.println("The number of hours is" + hours);
        System.out.println("The number of minutes is" + minutes);
        System.out.println("The number of seconds is" + seconds);
    }
}



So for instance if they entered 6245 seconds, here is what would happen. 6245 is entered into the scanner buffer, and then hours is calculated by 6245/3600, which would be 1. Temporary would be 6245%3600, which would be 2645. Minutes would then be 2645/60, which would be 44 minutes. Finally seconds would be 2645%60, which would be 5.

I am still a beginner though.. some of the out of class stuff my professor has made us do has been harder than this test was, so I may come to this thread for help at some time .
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
ComicBookGuru  





Joined: 16 Dec 2007
Posts: 1678

PostPosted: Thu Sep 30, 2010 1:49 am    Post subject: Reply with quote

For my Senior Project at school, I wrote a graphical simulation of the Gulf of Mexico. Bear with me, I'm a nub coder, but you can see my doe for it here: Heavy, heavy modification of a book's game, and slight modifications to its' engine

(It's lacking headers and stuff, and you won't be able to run it because it lacks images and stuff, but the source is for show, I guess).
_________________
Yep, I learned through Rocksmith!
Back to top
View user's profile Send private message
sorasgoof  





Joined: 09 Mar 2008
Posts: 2314

PostPosted: Thu Sep 30, 2010 1:56 am    Post subject: Reply with quote

I decided to get back into learning Python today. I noticed the IDLE wouldn't load. I uninstalled Python, installed the newest version, and guess what? It still won't come up. So much for that.
_________________

Check out my Youtube channel!
We have a Dead Space 2 Hardcore run coming out very shortly, an ongoing Portal Let's Play, an ongoing Super Mario RPG Let's Play, AND a Max Payne Let's Play in the works. Be a hipster! Follow Full Grown Gaming before most people do!
Back to top
View user's profile Wiki User Page Send private message XBL Gamertag: KyleSHG
Southparkhero  





Joined: 23 Aug 2008
Posts: 3251
Location: Some place in NJ.

PostPosted: Thu Sep 30, 2010 2:04 am    Post subject: Reply with quote

I just wanted to inform everyone that my Visual Basic class is a joke.
_________________
sdfadf
Back to top
View user's profile Wiki User Page Send private message
Urisma  





Joined: 04 Aug 2007
Posts: 220
Location: The Woodlands, Texas

PostPosted: Thu Sep 30, 2010 12:48 pm    Post subject: Reply with quote

sorasgoof wrote:
I decided to get back into learning Python today. I noticed the IDLE wouldn't load. I uninstalled Python, installed the newest version, and guess what? It still won't come up. So much for that.


Don't use IDLE. Install 2.7, and use pydev with eclipse. It's WAYYYYY better.
Back to top
View user's profile Send private message XBL Gamertag: TuftedToaster
Bj0rn  





Joined: 31 Aug 2007
Posts: 522
Location: Stockholm, Sweden

PostPosted: Fri Oct 01, 2010 11:14 pm    Post subject: Reply with quote

I'm gonna participate in this programming contest tomorrow. Wish my team luck, LOL
_________________
My accomplishment thread
Champion of 6 ScoreHero leagues:
S7: GH3X AAA-2
S10: GH3X AAA-1, GHAX
S11: GH3X AAA, GH5X AAA
S16: GH3X
My youtube channel
Back to top
View user's profile Send private message XBL Gamertag: BurningThunder
FoG  





Joined: 16 Jun 2007
Posts: 1854
Location: Under A Bridge...

PostPosted: Sat Oct 02, 2010 12:38 am    Post subject: Reply with quote

I've started taking a computer programming course at college since September, and it's going along great! Learning about Unix, Java, and the basic IT concepts along with English, Math, and Web Design/Programming. The Java course is Object-Orientated, and I've gone as far as to create my own class to do the calculations and such for my program. I'm hoping we get to GUI's soon as that will be really interesting to learn.
_________________


[quote=/"MarkMadness/"]i actually got my china cymbal today and put it on my head and sang china hat[/quote]
My YouTube - My Twitter - My Accomplishments
[quote=/"dudextr/"][10:02:26 PM] xtr: yeah, it''''s too painful now
[10:06:12 PM] xtr: it looks like i have chlamidya[/quote]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger XBL Gamertag: Scythera
Display posts from previous:   
Post new topic   Reply to topic    ScoreHero Forum Index -> General Chat All times are GMT
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 28, 29, 30  Next
Page 7 of 30

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Copyright © 2006-2024 ScoreHero, LLC
Terms of Use | Privacy Policy


Powered by phpBB