Pseudocode for this Python code (I wrote one but it does not match):
import random
def rollDice():
num1 = random.randint(1, 6)
num2 = random.randint(1, 6)
return num1, num2
def determine_win_or_lose(num1, num2):
total = num1 + num2
print(f"You rolled {num1} + {num2} = {total}")
if total == 2 or total == 3 or total == 12:
return 0
elif total == 7 or total == 11:
return 1
else:
print(f"Point is {total}")
return determinePointValueResult(total)
def determinePointValueResult(pointValue):
total = 0
result = -1
while total != 7 and total != pointValue:
num1, num2 = rollDice()
total = num1 + num2
print(f"You rolled {num1} + {num2} = {total}")
if total == pointValue:
result = 1
elif total == 7:
result = 0
return result
def main():
n = int(input("Enter the number of games to play: "))
i = 0
winCounter = 0
loseCounter = 0
while i < n:
num1, num2 = rollDice()
result = determine_win_or_lose(num1, num2)
if result == 1:
winCounter += 1
print("You win\n")
else:
loseCounter += 1
print("You lose\n")
i += 1
print(f"Game results: {winCounter} wins and {loseCounter} losses")
if __name__ == "__main__":
main()
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
- Mailings Review View Help AaBbC AaBbCcD AaBbCcD AaBbCc Aa Heading 1 T Normal 1No Spac. Heading 2 Hea Paragraph Styles 8. Consider the following equation for the sum of a finite arithmetic series: S, = n(a, ta where n is the number of elements in the series, a is the first element of the series, and a, is the last element of the series. Write a method that returns the sum of the elements stored in the array in 8 above. The array must be passed to the method as an argument. Your solution should implement the equation for the sum S.arrow_forwardprogramming used: javaarrow_forwardDo not copy from other websites (I will downvote) Correct and detailed answer will be Upvotedarrow_forward
- Variables Primitive Write a java program that asks the user to enter 3 integers. Add the integers and display “The total is “ the result Reference Write a java program that asks the user for their first name and last name. Display “Your full name is “ the first name and last name Arrays One-dimensional Write a java program that creates an array of integers called numbers and contains five elements. Then use a for loop to print them out using println(). Two-dimensional submit your code for the total of rows and total of columns herearrow_forwardPython question Application: Python Fragment Formulation (Q1 – Q4) In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task. Question 1 (Reduce parentheses) Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying. (x**(2**y))+(y*((z+x)**3)) Question 2 (Translate arithmetic concept into Python) You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers. Note: the product of two numbers, x and y is x*y. Question 3 (List/table access) You are given a table,…arrow_forwardPython Turtle: How do I fix the code to make it generate lakes as bigger random dots, and mountains as a separate color (gray) from the grass area? (Big error: lake generates as entire circle inside land, want it generating like mountains).AKA: How do I separate each of the values to generate on its own without conflicting eachother. import turtleocean = "#000066"sand = "#ffff66"grass = "#00cc00"lake = "#0066ff"mountain = [[-60, 115], [-65, 200], [-10, 145], [-30, 70], [50, 115], [100, 150], [70, 200], [30, 70], [10, 180], [-10, 220]]def draw_circle(radius, line_color, fill_color): my_turtle.color(line_color) my_turtle.fillcolor(fill_color) my_turtle.begin_fill() my_turtle.circle(radius) my_turtle.end_fill()def move_turtle(x, y): my_turtle.penup() my_turtle.goto(x, y) my_turtle.pendown()num_cuts = int(input("How many rivers do you want on your Island? ")) screen = turtle.Screen()screen.bgcolor(ocean)screen.title("Island Generator")my_turtle =…arrow_forward
- Pythonarrow_forwardDiscrete Mathematics: Assignment details: Replace all the 0 (Zero) digits in your ID by 4. Example: If your ID is 38104680, it becomes 38144684 Take the first 6 digits and substitute them in this expression (( A + B) / C) * ((D-E)/F)-2) according to the following table; Letter Replace by Digit Example Digit A 1st 3 B 2nd 8 C 3rd 1 D 4th 4 E 5th 4 F 6th 6 After substitution your expression will be similar to this (( 3 + 8) / 1) * ((4-4)/6)-2). Draw a rooted tree that represents your expression. What is the prefix form of this expression. 3.What is the value of the prefix expression obtained in step 2 above?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education