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



## Tatertsalad69 (Jul 19, 2021)

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.


----------



## Solaris17 (Jul 19, 2021)

Ask your teacher for clarification?


----------



## LFaWolf (Jul 19, 2021)

Have you learned data structures such as array?


----------



## Tatertsalad69 (Jul 19, 2021)

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



Tatertsalad69 said:


> 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 (Jul 19, 2021)

```
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.


----------



## Tatertsalad69 (Jul 19, 2021)

ShiBDiB said:


> ```
> tempData = [];
> 
> tempData.push(dailyTemp);
> ...


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 (Jul 19, 2021)

```
// 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);
```

Added some comments

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


----------



## Tatertsalad69 (Jul 19, 2021)

ShiBDiB said:


> ```
> // This creates an empty array called tempData
> tempData = [];
> 
> ...


Wow thank you so much! This helps a lot! and thanks for the spiritual boost.


----------



## moproblems99 (Jul 19, 2021)

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.


----------



## Tatertsalad69 (Jul 19, 2021)

moproblems99 said:


> Realistically, pseudo code is a human readable example of code.  Such as getting out of bed:
> 
> Open eyes
> Check clock
> ...


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 (Jul 19, 2021)

Tatertsalad69 said:


> 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.


----------



## Tatertsalad69 (Jul 20, 2021)

moproblems99 said:


> 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.
> 
> ...


I tried to clear it up more, here is an update (after about 15 others) I hope this makes better sense.


----------



## Space Lynx (Jul 20, 2021)

moproblems99 said:


> Realistically, pseudo code is a human readable example of code.  Such as getting out of bed:
> 
> Open eyes
> Check clock
> ...



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


----------



## Tatertsalad69 (Jul 20, 2021)

lynx29 said:


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


Lol it’s accurate enough


----------



## moproblems99 (Jul 20, 2021)

Tatertsalad69 said:


> I tried to clear it up more, here is an update (after about 15 others) I hope this makes better sense.


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

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



> ```
> for x in fruits:
> print(x)
> ```



At times, python is practically like writing pseduocode.


----------



## Tatertsalad69 (Jul 20, 2021)

moproblems99 said:


> It's better but look at how a few languages loop through data.
> 
> https://www.w3schools.com/python/python_for_loops.asp
> 
> ...


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 (Jul 20, 2021)

Tatertsalad69 said:


> 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.


----------



## Tatertsalad69 (Jul 20, 2021)

moproblems99 said:


> 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.


Lol I appreciate it! I like learning and I enjoy challenges, is why I play my games on hardest modes off rip.


----------

