Type in an integer and then raise it to the power of another integer. r its like a joker variable only used to save the value o “a” in order to keep going inside the while loop, until the “b” its equal to one.
The second program of the quiz, print the number the user type in, and returns the number of stars corresponding to the number the user wrotes. The trick its not doing the string “*” times de number, you need to find another way.
I used a while loop in order to append one by one star into the list, then another while loop to print the list, when an end=”” it means that it will print a space and not a new line.
This program will sum all the integers in a range provided by the user(low and high).
But the thing gets more intersting when you add a condition, what if the user enter the range flipped. My solution was simple, using another variable(joker) to keep rolling the values of the variables until the boundries are flipped.
Also used a counter and a while loop, because you start at the lower value(once you flipped if needed) and you know that the point to stop will be de upper value, so you just keep to adding 1 to the lower value and keep adding it to the same lower value.
At the end joker is equal to lower, because you need the original value of lower if you want to display to the user, just to remaind them, the range they provide.
The main purpose of this program is that the user guess a number from 1 to 100. Display the user the number of tries and it give you hints of low and high, close to the number.
The first thing you need to do is import the random library in order to generate a random number each time the program executes, this random number will be between 1 and 100. Also you need to use a counter staring at 0, later you will use it to display the number of times until the user guess the number.
In this case I use a while loop because I know that the point to stop its when the guess of the user its equal to the random number, so as long as the guess of the user its different, the while loop will repeat but with several conditions using if, elif that includes when the number its out of both boundries and when the number is high or low.
At the end when the user wins, the while loop ends and the random number is printed, the number of time you try as well.
I did two runs, you can see the random number its not the same.
In order to make this program work properly I use a str(input()) to make sure that the user only type in string and not any other character. Then the logic is simple, just by using some if and elif that validates the user choice, and an else at the end that display if the user enter an invalid character.
Then I use a int (input()) just to make sure that the user type in a number and if the temperature that the user type in is higher than the boilling point of water, it will display that information and the final temperature.
Remember that the if statement use a parameter as a condition defined by you, and when this is true the interpeter will run that part of the code and ignores all the code remaining. If the If statement is not true then it will pass to an elif statement when you can write another condition, at the end an else statement is used as the default option if not of the above is true. (if x<y:) and do not forget to ident well
Its very intersting concept to abolish grade, because sometimes you know all the stuff that you have seen in class but your grade does not match with you knowledge. If you want to learn you will do it no matter what, and if you want to lose your time youre gonna do it and its not the teacher fault if students didnt came with any doubts to the classroom. But by grading them you are adding compromise to just do the stuff in order to pass and not in order to learn.
This is my code written in atom and running in the command prompt. The only thing you need to know in order to do this are two basic things. Asking the user for an input in this case specifically for an integer; And the basic math operators that are + – / * and the residual function mod that gives you the remainder of the division, if there is any.
This was an easy task. Write my code using atom and run it in the command prompt in order to print “Hello World”.
cd is the way the terminal understands that you want to switch to another folder in order to execute the code(the folder you save your code). Then you need to tell the terminal you want to run it using python version 3.5 (Python35) and calling the executable python.exe and the name of the code.
I previously had installed python 2 and a previous version of python 3
The only thing I did was to upgrade to the most recen version of python 3 from python.org page
To write my code I use Atom and when I run it the command prompt works fine, or I can use the IDLE integrated with windows or Aptana that works for both purposes.