# Generating pseudocode to track the daily temperature of a month.

##### New Member
So I am new to coding and in my class we are learning flow charts and pseudocode, I am currently tasked with several projects one of which is to generate a pseudocode to track the daily temperature of a month. I am having a hard time understanding how to do this, I know that this will not be syntax accurate and it is a logical direction. But when I view examples of pseudocode I can’t find one for tracking data like this, and am getting mixed understandings on how I should write it out. I did write out what I think is okay, but it clearly is bulky and hard to read. I have attached a photo, if anyone can help me make this look better I would appreciate it. Any advice will be greatly appreciated.

#### Attachments

• image.jpg
1.7 MB · Views: 59

Staff member

#### LFaWolf

Have you learned data structures such as array?

##### New Member
We are learning that now. It was mentioned to a degree but was told we would learn more later in the book.

We are learning that now. It was mentioned to a degree but was told we would learn more later in the book.
I’m not very sure on how to use them yet I understand they can be used to “compress” a lot of variables into a more understanding line. But that is as far as I have learned. I’m looking for alternative sources to study along with my books. If you have any websites I can visit that would be greatly appreciated.

#### ShiBDiB

Code:
``````tempData = [];

tempData.push(dailyTemp);

avg = sum(tempData) / tempData.length;
max = max(tempData);
min = min(tempData);``````

I don't actually know what counts as "pseudocode".. So that's basically just JS simplified.

"[]" is an array, so for this example would be filled with [90, 87, 78, 90, etc, etc]

If you needed to be able to pull specific date data you'd be better off using an object to store the data with the actual date as the identifier.

##### New Member
Code:
``````tempData = [];

tempData.push(dailyTemp);

avg = sum(tempData) / tempData.length;
max = max(tempData);
min = min(tempData);``````

I don't actually know what counts as "pseudocode"
Wow this looks a lot better than mine haha I’m definitely a total noob at this. It might be asking a lot but can you explain each part of this in layman’s terms. I’m a hands on learner and the more something is broken down in detail the better I can understand it.

#### ShiBDiB

Code:
``````// This creates an empty array called tempData
tempData = [];

// This stores the current daily temp in the array (doesn't loop, assumes this code would be run for every day)
tempData.push(dailyTemp);

// A fake function "sum" adds all the entries in the array together, then divides it by the array length to get the average
avg = sum(tempData) / tempData.length;
// Fake function that finds the max
max = max(tempData);
// Fake function that finds the min
min = min(tempData);``````

I don't know if the teacher assumes this is a live recording thing or if it's using historical data. If you're using historical data you'd have to put the '.push' line in some type of loop (for/while/etc..) to store all the historical data into the array.. but then you'd also not even need the array, so I'd guess they're not looking for you to get that in depth with it.

I'm self taught so some of my early stuff looked a lot worse than what you've got

##### New Member
Code:
``````// This creates an empty array called tempData
tempData = [];

// This stores the current daily temp in the array (doesn't loop, assumes this code would be run for every day)
tempData.push(dailyTemp);

// A fake function "sum" adds all the entries in the array together, then divides it by the array length to get the average
avg = sum(tempData) / tempData.length;
// Fake function that finds the max
max = max(tempData);
// Fake function that finds the min
min = min(tempData);``````

I don't know if the teacher assumes this is a live recording thing or if it's using historical data. If you're using historical data you'd have to put the '.push' line in some type of loop (for/while/etc..) to store all the historical data into the array.. but then you'd also not even need the array, so I'd guess they're not looking for you to get that in depth with it.

I'm self taught so some of my early stuff looked a lot worse than what you've got
Wow thank you so much! This helps a lot! and thanks for the spiritual boost.

#### moproblems99

Realistically, pseudo code is a human readable example of code. Such as getting out of bed:

Open eyes
Check clock
If weekend:
--> set alcohol to whiskey
Else:
--> set slcohol to tequila
While day sucks:
--> drink alcohol

If you submit code, your instructor is going to kick your ass.

Last edited:

##### New Member
Realistically, pseudo code is a human readable example of code. Such as getting out of bed:

Open eyes
Check clock
If weekend:
--> Open whiskey
Else:
--> Open tequila

If you submit code, your instructor is going to kick your ass.
Lol okay I’ll avoid getting my ass kicked then. So my pseudocode is bulky and too much. If I was to simplify it I could just say what the step is and not show every variable like I did?

#### moproblems99

Lol okay I’ll avoid getting my ass kicked then. So my pseudocode is bulky and too much. If I was to simplify it I could just say what the step is and not show every variable like I did?
It really depends on how much detail they want. Mine was minimal. You'll have to feel it out.

Remember pseudo code is in-between your normal human language and code. Use standard statements like if, else, then, for etc. But you can write it so a human can read it. Generally, write pseduocode like real code - one statement at a time.

Pseudo code is not specifications so you don't need to define arrays and stuff like that.

The goal of pseduocode is for the engineer to give to the code monkey so they can write it in the language that best suits the project.

Point number 2: pseduocode should be programming language agnostic.

For your specific case, I would think your pseduo code could be less than 20 words, total, all statements combined.

Last edited:

##### New Member
It really depends on how much detail they want. Mine was minimal. You'll have to feel it out.

Remember pseudo code is in-between your normal human language and code. Use standard statements like if, else, then, for etc. But you can write it so a human can read it. Generally, write pseduocode like real code - one statement at a time.

Pseudo code is not specifications so you don't need to define arrays and stuff like that.

The goal of pseduocode is for the engineer to give to the code monkey so they can write it in the language that best suits the project.

Point number 2: pseduocode should be programming language agnostic.

For your specific case, I would think your pseduo code could be less than 20 words, total, all statements combined.
I tried to clear it up more, here is an update (after about 15 others) I hope this makes better sense.

#### Attachments

• image.jpg
1.9 MB · Views: 14

#### lynx29

Realistically, pseudo code is a human readable example of code. Such as getting out of bed:

Open eyes
Check clock
If weekend:
--> set alcohol to whiskey
Else:
--> set slcohol to tequila
While day sucks:
--> drink alcohol

If you submit code, your instructor is going to kick your ass.

is this what elon musk is referring to as evidence our entire existence could be a coded program?

##### New Member
is this what elon musk is referring to as evidence our entire existence could be a coded program?
Lol it’s accurate enough

#### moproblems99

##### New Member
It's better but look at how a few languages loop through data.

https://www.w3schools.com/python/python_for_loops.asp

At times, python is practically like writing pseduocode.
Oh I see, geez I need to learn better the meaning for “if, then, while, etc”. My understanding is limited at the moment and not knowing fully how to utilize these is hindering my work. Looks like it’s vocab time. Thank you for all your help! It has really brought me closer to understanding what I am writing. I’ll post another update when I revise my work once more. Your awesome!

#### moproblems99

Oh I see, geez I need to learn better the meaning for “if, then, while, etc”. My understanding is limited at the moment and not knowing fully how to utilize these is hindering my work. Looks like it’s vocab time. Thank you for all your help! It has really brought me closer to understanding what I am writing. I’ll post another update when I revise my work once more. Your awesome!
Any time! The start of CS is the best. Everything still feels magical and impressive.

I'm also doing my best not to just tell you. Harder than it sounds.