Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Python Programming Mahyar S Vaghefi University of Texas Arlington Assignment #1 ¶ Question 1: 1. Write python code the prompts the user to input the following information: Name, birth year, favorite...

1 answer below »

Python Programming
Mahyar S Vaghefi
University of Texas Arlington
Assignment #1 ¶
Question 1:
1. Write python code the prompts the user to input the following information: Name, birth
year, favorite food.
2. Compute the age of the user.
3. Display the following message to the user three times:
"Hello [NAME]. I just figured out that you are [AGE] years old, and that your favorite food
is [food]."
Use the "fstring format" to display the message for the first time
Use the following structure in print function to display the second message: print( , ,
). - Note: Use as many commas as needed.
Use the following structure in print function to display the third message: print( + +
). - Note: Use as many +s as needed.
4. Make sure to put comment for every line in your code
5. Use camelCase style to name your variables.
In [ ]: # Write your code over here.
Question 2:
Consider the following formula for conversion of Fahrenheit to Celsius:
1. Write a Python program that prompts the user to choose between converting 1.
Fahrenheit to Celsius and 2. Celsius to Fahrenheit.
2. User should enter his/her option by entering 1 or 2.
3. After receiving user input, use an if-else structure to display the appropriate message to
the user in order to obtain the input value for the desired temperature. (For instance, if
the user enters 1, your code should display "Please enter the Fahrenheit temperature"
and display "Please enter the Celsius temperature" otherwise.)
4. Once again, use an if-else structure to perform the co
ect conversion and display the
appropriate message to the user (for instance: "[X] degree of Fahrenheit is equal to [Y]
degree of Celsius").
5. Make certain that when displaying temperatures to users, you always format in 2-
decimal places.
! = " + 3295
In [ ]:
Question 3:
1. Write a program that display the following pattern:
2. Update your previous code to get the user's number of * in the first line. The user should
in put a value between 1-10. For example, if the user input 8 the output should be:
Tip: You need to use loop and if condition in your code.
# Write your code over here.
In [ ]:
In [ ]:
Question 4:
1. Write a program that takes a digit input value between 0 and 9 and converts it to an
equivalent English word (For example, if the user enters 0, the program should display
"you entered zero.", or if the user enters 2, the program should display "you entered
two.") [important: user if-elif-else structure for this question].
2. Update the code in Part #1 of your code so that the program continues to ask the
question and display the output until the user enters -1 as an input. [Note: Make sure
that your program clearly provide instruction to user so she knows that -1 will stop the
program.]
3. Write your code outside the jupyter platform and save it as My_Assignment1.py . Make
suree to submit the file separately in Canvas.
4. (Extra point) Update your the code in Part #2 that clear the content of previous iteration
efore asking for the input from the user.
In [ ]:
In [ ]:
In [ ]:
Question 5:
Write a program with a loop that asks the user to enter a series of positive numbers. The
user should enter a negative number to signal the end of the series. After the user has
entered all of the positive numbers, the program should display the total number of odd
numbers entered by the user.
In [ ]:
Question 6:
# Write the the answer for the part #1 over here
# Write the the answer for the part #2 over here
# Write the the answer for the part #1 over here
# Write the the answer for the part #2 over here
# Write the the answer for the part #4 over here
# Write your code over here.
Write a program that generate the following output:
Tip: You need to use nested loop.
In [ ]:
Question 7:
Your task is to create a simple game. In order to implement the game, you must use the
function structure in your program. In this game, the user must virtually roll two dices. Afte
olling the first dice, the program should display the dice number and prompt the user to
guess the sum of the two dices. After the user enters his/her guess, the program should roll
the second dice and display "You won the game" if the sum of the two dice was equal to the
user's guess, otherwise display "You lost the game." The program should continue till the
time that user wants to keep playing.
In [ ]:
Question 8: Modify the folowing code in a the main function in a way that the output for the
sample_function displays: "the variable value is 150"
Note: You can only add code to the main( ) function.
In [ ]:
# Write your code over here.
# Write your code over here.
my_value = 120

def main():
sample_function()

def sample_function():
print(f'the variable value is {my_value}')

main()
Question 9: Create an is prime Boolean function that takes an integer number as an
argument and returns true if the argument is a prime number and false otherwise. Save you
function in a separate module as myPrimeDetector.py. Import your module here and use the
is_prime function in your program so that it prompts the user for a number and then displays
a message indicating whether the number is prime or not.
In [ ]:
Output:
You need to provide answers in the designated cell for each question.
You need to make sure that your final file contains both codes and results (don't clea
the outputs).
Save your file in the .ipynb format (as it is right now).
Upload your file into Canvas (Assignment #1)
You should also upload any other .py file that the assignment ask you to creat.
All the assignments should be submitted by Friday Feb 25 at 11:59 AM. No late
submission will be accepted
I will not accept any submission by email or any other method, so make sure that you
submit the file in a right place at a right time.
# Write your code over here.
Answered Same Day Feb 21, 2022

Solution

Arun Shankar answered on Feb 22 2022
107 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here