• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Generating pseudocode to track the daily temperature of a month.

Tatertsalad69

New Member
Joined
Jul 19, 2021
Messages
9 (0.01/day)
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
    image.jpg
    1.7 MB · Views: 577
Ask your teacher for clarification?
 
Have you learned data structures such as array?
 
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.
 
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.
 
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.
 
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);

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 :P
 
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);

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 :p
Wow thank you so much! This helps a lot! and thanks for the spiritual boost.
 
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:
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?
 
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:
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
    image.jpg
    1.9 MB · Views: 320
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?
 
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!
 
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.
 
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.
 
Back
Top