Python 3 Not Backwards Compatible with Python 2

preview_player
Показать описание
Understanding why the example program would not run in Python 3 and how to fix it.
Рекомендации по теме
Комментарии
Автор

It's not only the print() and input(). If I remember correctly, simply making a function return was a statement before, now it is a function (like print "something" is now print("something")). Furthermire, the i/o-stuff has changed. I don't know if there are other important differences, but these round up the given examples in the video.

Permafrostrock
Автор

Moaaaar! These are AWESOME. I can't wait for you to cover some deeper topics, but these are brilliant. Thanks!

bearchildofdeath
Автор

Instead of doing eval(input("Enter a non-negative integer to take the factorial of: ")), you can do int(input("Enter a non-negative integer to take the factorial of: ")) for Python 3. FYI :-).

thebestbestman
Автор

Programming tutorials from Khan! Excellent! May I suggest doing solutions for project euler?




computerex
Автор

omg i never knew u did programming stuff on Khan Academy! This is AWESOME!

camelCaseFTW
Автор

Also:
number = int(raw_input("enter a positive integer: "))

works fine :D

computerex
Автор

You maybe want to introduce viewers to the concept of types (the type() function in Python will return the type of variable). raw_input() in Python 2 returns a string. input() in Python 2 expects Python syntactically correct input and returns the input evaluated with the correct type (so you could enter '[1, 2, 3]' and it would evaluate this to an actual list).

parkamark
Автор

@944Nima By that I mean a language such as java or c++ where in my opinion the object oriented aspect is much more pronounced and is much more applicable to developing large pieces of software by using large complex objects and classes. Python doesn't hold a candle to the major object oriented languages it is primarily a scripting language.

slsl
Автор

@944Nima I'm curious about what features you are referring to as C++ has a very rich set of features when it comes to OOP.. When they designed Java they actually chose to skip some of those features like multiple inheritance.

kacklal
Автор

What do you use for drawing on the screen? I'm interested in the hardware & software.

I'm looking forward to watching all the Python videos you produce, I just found out about Kahn Academy, thanks so much!

zbuffered
Автор

I get a 'run in parallel' error no matter what I try to do regarding this first line of code

sedenions
Автор

Any chance of later doing videos in more object oriented languages?

slsl
Автор

In general using eval() on a user input is a really bad idea. The user can input any code, say something to delete the contents of your hard drive, and your program would run it.

PeterCollingridge
Автор

@angeldown Why is it even like this though? Why are their different commands for certain variables. I know in Basic and C++, you would delcare a variable and then use the same input type to put whatever you needed into it.

ForeverWiked
Автор

Is there a function that converts the string into an integer?
Like this: convertInt(input("Blah blah blah: "))

SilentPixel
Автор

Oh hell yes, compsci/programming on my khan academy? Do want.

twincannn
Автор

why would they switch a number variable to a string variable -___-

ForeverWiked
Автор

Computer science on Khan Academy? My life is complete

loopuleasa
Автор

i am going to put khan academy on my resume

frozenstrawbs
Автор

Sal Kahn you sound like Samuel L Jackson, did you know that?

PatrickAllenNL