Python (2 Different Questions) - 1. Given This Stri.
Python (2 Different Questions) - 1. Given This Stri.
NEW!
Textbook Solutions Expert Q&A Practice Search
home / study / engineering / computer science / computer science questions and answers / python (2 different questions): 1. given this string: chain…
Post a question
Welcome to Chegg Study, your start to better grades Show me around Answers from our experts for your tough
homework questions
Question: Python (2 different questions): 1. Given this string: chain = "ABC… Enter question
def roll(self):
"""
Rolls the die to come up with a pseudorandom value between 1 and 6.
"""
self.value = randrange(1,7)
Write a main program that creates two objects of class Die and rolls them both 10 times. After each roll,
print the value of both dice so you can visually inspect the output to see how many pairs you rolled. Your
program must use a loop to roll 10 times instead of repeating code.
Your Answer:
Expert Answer
chain = "ABC1DEF2G"
lengthchain=len(chain);
for i in range(0,lengthchain-2):
print(chain[i:i+3]);
import random
class Die:
"""
One object of this class represnts one die with 6 sides. You can roll the die
to come up with a pseudo random value between 1 and 6.
"""
def __init__(self):
"""
Initializes the die to 1.
"""
self.value = 1
def __str__(self):
"""
Returns a string representation of the die.
"""
return "This die has value : " + str(self.value)
def roll(self):
"""
Rolls the die to come up with a pseudorandom value between 1 and 6.
"""
self.value = random.randrange(1,7)
def main():
dice1=Die();
dice2=Die();
for i in range(0,10):
dice1.roll();
dice2.roll();
print(dice1,dice2);
if __name__ == '__main__':
main()
Comment
Q:
Python Language Problem Please complete the function get_trial_result() and use the test code provided. These are the
definitions of the trial decisions, given a jury of 9 jurors: Guilty - Unanimous; all 9 juror decisions are guilty Guilty - Split; at
least 7 juror decisions(Super Majority) are guilty Hung Jury - Mistrial; less than 7 juror decision are guilty Not Guilty - No
juror...
A:
See answer
Q:
[Java] A palindrome is a word, phrase, or sequence that reads the same backward as forward. Example: madam, civic, kayak,
racecar, mom, dad, noon, rotor, radar, etc. Your task is to read a String input by the user and determine whether the String is
a palindrome or not. Your submission needs to be a word document and it must include a screenshot of the result of
entering a...
A:
See answer
100% (1 rating)
Show more
ABOUT CHEGG LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE
Become a Tutor Advertising Choices Cheap Textbooks Online Tutoring Easybib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Solutions Manual Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Study 101 Studyblue Help with Chegg Tutors
Corporate Development Intellectual Property Rights Chegg Study Help Test Prep Help with eTextbooks
Investor Relations International Privacy Policy College Textbooks Textbook Rental Help to use EasyBib Plus
Jobs Terms of Use eTextbooks Used Textbooks Manage Chegg Study
Join Our Affiliate Program Chegg Tutors Terms of Service Chegg Math Solver Digital Access Codes Subscription
Honor Code