Generate a random number between 1 and 100. That will be the number that the user should guess. Please print the random number. Generate a random number by using the random.randint function Try several times to check that the number produced is random.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
In Python lang.
ONE
- Generate a random number between 1 and 100. That will be the number that the user should guess. Please print the random number.
- Generate a random number by using the random.randint function
- Try several times to check that the number produced is random.
TWO: 0010
- Create a variable and ask the user to input a number.
- Ask the user to input a number in a variable that will be rewritten every time the user inserts a number and
Enforce the rules:
- Enforce that the input is a digit from 1 to 100.
- Give feedback to the user if the number needs to meet the rule.
- Allow the user to input the number again.
If the number meets the rules, convert the input [a string] into an integer and evaluate if the guessed number is the same as the randomly generated number
FOUR:
Evaluate if the randomly generated number is the same that the number input by the user.
FIVE:
- Use the dictionaries that you created for faculty members.
- Be sure that all the dictionaries have the same keys: name, last name, etc.
- If there are keys or values missing, add them. If you do not have the value, you can use 'n/a' or 'TBD'.
- Make a list of the dictionaries.
- Loop the list to print all the information available to each faculty member.
SIX:
Make a dictionary with the US states and their capitals (listed at the end of this file). The keys will be the states, the capitals will be the values. i.e. 'New York' : 'Albany'
- Use a loop to print 50 messages, one for each of the 50 states, that say:
‘Albany city is the capital of New York state.'
- Use a loop to print the 50 names of the states adding at the end the word state and a dot. Use end=.
- Use a loop to print the 50 capitals and add at the end the word city and a dot.
- Slow back the process by 2 seconds by using the time method.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images