background preloader

Programação

Facebook Twitter

School of Engineering - Stanford Engineering Everywhere. Howstuffworks. Building Blocks for Theoretical Computer Science. CODING FOR GOOD.

Ideas

HS. Dance Party Grades 2+ | Blocks Minecraft Hour of Code A Minecraft Tale of Two Villages Grades 2+ | Blocks, Python Make a Flappy game Play, Design & Code Retro Arcade Games codeSpark Academy with The Foos: Create Games Pre-reader - Grade 5 | Blocks Star Wars: Building a Galaxy with Code Grades 2+ | Blocks, JavaScript Coding Town. Getting to Know You - Getting Started with Programming. Problem 7. JavaScript length Property. Functions. Buy this book at Amazon.com 3.1 Function calls In the context of programming, a function is a named sequence of statements that performs a computation.

Functions

When you define a function, you specify the name and the sequence of statements. Later, you can “call” the function by name. We have already seen one example of a function call: >>> type(32) <type 'int'> The name of the function is type. It is common to say that a function “takes” an argument and “returns” a result. 3.2 Type conversion functions Python provides built-in functions that convert values from one type to another. >>> int('32') 32 >>> int('Hello') ValueError: invalid literal for int(): Hello int can convert floating-point values to integers, but it doesn’t round off; it chops off the fraction part: >>> int(3.99999) 3 >>> int(-2.3) -2 float converts integers and strings to floating-point numbers: >>> float(32) 32.0 >>> float('3.14159') 3.14159 Finally, str converts its argument to a string: Using Xcode to learn C++

"Hi!

Using Xcode to learn C++

I'd like to learn to swim! " "Noooo! Swimming is bad! Here's a site on jogging... " Capt. Objective-C is a *wonderful* language, and in my mind, a much better language than C++. That being said, I do 95% of my current work in C++, because that's what the task called for this time around, but I vastly prefer Obj-C. Obj-C has the strongest support on the Mac, but it's not Mac-exclusive. What *isn't* available on other platforms, however, are the Cocoa libraries, which are the magic secret sauce that make programming for the Mac so damned nice. Now, you may be thinking 'which one? ' So if you're looking at using gaming libraries that are already out there, you're almost certainly going to need to know C++. C is a very low level language, and a pain in the ass in many ways, but it does form the core of both C++ and Obj-C, and will serve you well in those capacities.

0.6 — Compiling your first program. Before we can write our first program (which we will do very soon), we need to know two things about development environments.

0.6 — Compiling your first program

First, although our programs will be written inside .cpp files, the .cpp files themselves will be added to a project. Some IDEs call projects “workspaces”, or “solutions”. The project stores the names of all the code files we want to compile, and also saves various IDE settings. Every time we reopen the project, it will restore the state of the IDE to where we left off.

When we choose to compile our program, the project tells the compiler and linker which files to compile and link. Second, there are different kinds of projects. Traditionally, the first program programmers write in a new language is the infamous hello world program, and we aren’t going to deprive you of that experience! A quick note about examples containing code Starting with this lesson, you will see many examples of C++ code presented. Exercise 13: Parameters, Unpacking, Variables. In this exercise we will cover one more input method you can use to pass variables to a script (script being another name for your .py files).

Exercise 13: Parameters, Unpacking, Variables

You know how you type python ex13.py to run the ex13.py file? Well the ex13.py part of the command is called an "argument. " What we'll do now is write a script that also accepts arguments. Type this program and I'll explain it in detail: On line 1 we have what's called an "import. " The argv is the "argument variable," a very standard name in programming, that you will find used in many other languages. Line 3 "unpacks" argv so that, rather than holding all the arguments, it gets assigned to four variables you can work with: script, first, second, and third. After that we just print them out like normal.

I call them "features" here (these little things you import to make your Python program do more) but nobody else calls them features. From now on we will be calling these "features" that we import modules. Are the command line arguments strings? Web Store do Chrome - Página Inicial.