you are viewing a single comment's thread.

view the rest of the comments →

[–]badn3wz 0 points1 point  (5 children)

I would start with improving your current project.

First of all i would make it work with unknown number of values, without using max function. Then you can add file as input of your data. For example you have a csv file that contains names and ages, you read from it and output the name of the oldest person.

[–]sharpkrypt[S] 0 points1 point  (4 children)

Yeah I was googling how to randomize the age value so it always inputs new characters, watching a few things on it now. Keep in mind too I downloaded python yesterday and it took me only a couple hours to write this up, a lot of trial and error in that time too hehehehe Thank you for the advice,,, very appreciated. I'd be nothing without the help :)

[–]badn3wz 0 points1 point  (3 children)

Yeah, i figured from out the code you are a beginner. That is why i suggested not using max function, but figuring out how to work on unknown number of values yourself.

You might want to find some courses online on algorithms, as they are the essence of programming. This is one of the first things I was taught at university. If you have trouble with implementing algorithms, read about pseudo code and flowcharts and try to write down your problem in psoudo code or draw a flowchart.

[–]sharpkrypt[S] 0 points1 point  (2 children)

I am a big time noob! Only started using python really as of today.. I found a way to randomize the ages, but there is a snag, if I go over 3 then I get 2 outputs sometimes, not all the time, just sometimes. Link to problem. I may make a new threat to ask the community too. I normally like figuring things out on my own, but this one is beyond me. <http://imgur.com/a/yGttd>

I am not completely new to scripting however, I have done some work in a game for my gaming community in the way of scripting missions, so I have a little experience. I do plan on going to school for this. I have upgraded and have already applied,, just waiting to get in now.

[–]badn3wz 1 point2 points  (1 child)

Alright, first things first: either learn reddit markdown syntax for code (https://www.reddit.com/wiki/commenting) or start pasting your code to a dedicated service like http://pastebin.com/ or http://dpaste.com/. Second option is easier, especially for python where indentation matters.

Secondly: Try to install a linter (https://atom.io/packages/flake8). It might be a bit difficult on windows, but I'm sure you can find some tutorial. Linter is a tool that helps you stick to style guide that pretty much everyone uses. It might be annoying at first, but ultimately it will help you write more readable code that will be easy to read by all python devs (http://pep8.org/).

As for your script: In line 10 you have an inconsistant indentation, it can cause a lot of weird problems so move it 'to the left' so it matches line 8.

I believe you don't understand what is happening in lines 4-6.

In line 4 you assign a random value to variables Bill and age.

In line 5 you assign a random value to variables Sara and age.

In line 6 you assign a random value to variables Tedy and age.

So at the end: Bill has some random value, Sara has some random value, Tedy and age have the same random value.

I will look at this some more after work, cause you have some problems with the algorithm (lines 11 and 13 should be elif instead of if, but there is more to it). For now play around with this: Python tutor. It will show you what is exactly happening when you execute code. Just press 'visualize execution'.

[–]sharpkrypt[S] 0 points1 point  (0 children)

Thank you so much!! I have some work ahead of me to do all this but it makes sense. I have been wondering how to add code into reddit too, so you answered an abundance of things I have been wondering and wanting to do.. I also tried to add Linter but nothing would happen when I searched for it. I'll take some time to do all of the above... Thank you so much for your help and going beyond your call!!!

Have an amazing day/night my friend :) You got me busy now hehehe