Does the AP Pseudocode instruction input () always return a string?

The AP function input () specifies “accepts a value from user and returns it”. Does this mean it always return a string? There is no software to cast a string to another data type.

Hi Bill!

I think that’s implied, and I don’t have any reference so this is just my guess, but the fact that the documentation doesn’t state that type of detail makes me think it won’t matter on the exam (as in, there won’t be a question with say integer input requiring students to distinguish string from integer).

Pseudo code has type casting beyond our wildest dreams so it doesn’t matter either way.

I believe like you it really does not matter, but assumptions can get you in trouble. It would be nice to explicitly specify. In python, input() always returns a string. In the AP CSP Exam Study Guide, the College Board discusses differences between their pseudo code instructions and javascript which lead me to my question. I’ve got two Monarch butterfly chrysalises right now.

I hear what you are saying.

I would say that pseudocode inputs both strings and numbers. Strings are identified by having " " around them. Numbers have an absence of letters. That is because we use pseudocode to code algorithms and pose test questions.

So for example we would write up a code sample and code something like x <- input(). In the question, we might ask: What will the program output if the input is “hello world”? Or we might ask what will the code do if the input is 100? We inherently understand that it will handle it correctly without a problem because it is intended for human consumption.

I have four Venus’ Flytraps that eyeball your butterflies with bad intent.

I agree that the pseudocode input is flexible to handle both (but yes, also admitting I have no reference so it doesn’t really answer your question, Bill). Bill, in the image you posted, I interpret that to mean the “input ()” block does what all the JavaScript blocks do.

My monarch season was a complete wash. In August I moved up to Washington state where it is too chilly and wet for me to start growing milkweed at this time. Impressive that you’re still getting some well into fall.

@jdonwells - can Venus Flytraps really capture a monarch butterfly?? Maybe Venus Flytraps come in bigger sizes than I know of. I had one when I was a kid. We had no flies to feed it, so my sister and I put candy in them. They did not survive.

Nobody collects carnivorous plants from the wild anymore. So they are mostly grown by division and tissue culture. The greenhouses have created selectively breed variants that are quite large. A monarch would probably not be attracted to them anyway. However, given a chance, they will try to eat a butterfly.

Yes, sugar in the traps does kill them. As does any animal meat. They like live insects only.

There is nothing in the AP Pseudo code that ever would trip students up on the type of the variable. It’s all basically ignored.

@crankings - That study guide that you have is not anything from the College Board. I put that together years ago to help my students review topics that I thought they needed to brush up on for the exam. I am surprised at the life it has taken on. My latest version has 55 pages. I wonder what version you have. I have not even thought about what it needs to look like this year. I’m hoping most of it is still valid but I’m sure I need to add things and hopefully take a couple of things out (maybe mod can go away?)

Sorry don’t have much to add to the monarch vs venus flytrap discussion except that i also had one as child and even though i didn’t feed it candy, it also did not survive long.

I know the College Board has eliminated hexadecimal and the Explore Task. Create Task is 40% and the exam is 60%. I will let you of other items I find. I believe I found your material through the code.org forum. Thank you