Apr-11-2018, 05:31 PM
(This post was last modified: Apr-11-2018, 05:31 PM by redwolf513.)
Hi all, (questions to do with IF, while functions)
I am taking a beginning python coding class for arcgis and am having some trouble figuring out two of my lab questions. I have never done any coding before beside R but I do not think that counts. We are in the first weeks of class and I fully admit I am lost. My teacher isn't very helpful at the current moment, she keeps sending me back to the book which I have reread multiple times.
Question one:
Write a series of Python statements that will prompt the user for three strings. Then, using an if statement, print them in alphabetical order.
what I have so far and have gotten stuck on:
>>> word_1=raw_input ("inset word:")
>>> word_2= raw_input ("insert word:")
>>> word_3=raw_input ("insert word:")
>>> list= (word_1 + word_2 + word_3)
>>> print list
I figured the next thing to do was sort my list but the function keeps throwing an error. I am also unsure how to make this into an IF statement. I figured the first thing I should do is see if I could even make inputs into a list I could sort. Since out reading talked about such things. The reading examples for if statement are all numerical so not sure how it works with non-numerical.
Question two:
Using a while loop, produce a simple table of sines, cosines and tangents. Make the variable x range from 0 to 3 in steps of 0.1. For each value of x, print the value of x, math.sin(x), math.cos(x) and math.tan(x).
if have to admit I am not even sure what this question is asking. I learn best by examples and have no example to how to even approach this. I am not asking for anyone to do the code for me but if someone could send me to an example that is similar to this question that would be amazing
I am taking a beginning python coding class for arcgis and am having some trouble figuring out two of my lab questions. I have never done any coding before beside R but I do not think that counts. We are in the first weeks of class and I fully admit I am lost. My teacher isn't very helpful at the current moment, she keeps sending me back to the book which I have reread multiple times.
Question one:
Write a series of Python statements that will prompt the user for three strings. Then, using an if statement, print them in alphabetical order.
what I have so far and have gotten stuck on:
>>> word_1=raw_input ("inset word:")
>>> word_2= raw_input ("insert word:")
>>> word_3=raw_input ("insert word:")
>>> list= (word_1 + word_2 + word_3)
>>> print list
I figured the next thing to do was sort my list but the function keeps throwing an error. I am also unsure how to make this into an IF statement. I figured the first thing I should do is see if I could even make inputs into a list I could sort. Since out reading talked about such things. The reading examples for if statement are all numerical so not sure how it works with non-numerical.
Question two:
Using a while loop, produce a simple table of sines, cosines and tangents. Make the variable x range from 0 to 3 in steps of 0.1. For each value of x, print the value of x, math.sin(x), math.cos(x) and math.tan(x).
if have to admit I am not even sure what this question is asking. I learn best by examples and have no example to how to even approach this. I am not asking for anyone to do the code for me but if someone could send me to an example that is similar to this question that would be amazing