beginner – Coin Flip Streaks – correct streak condition

This is a practice task from Automate the Boring Stuff with Python. I imagine many others have asked for their version of the solution to be checked, so I apologise beforehand for boring you yet again.

In brief, the task entails writing a code that carries out an experiment of checking if there is a streak of 6 ‘heads’ or ‘tails’ in 100 coin tosses, then replicates it 10,000 times and gives a percentage of the success rate.

``````import random
numberOfStreaks = 0
listOf100 = ()
streak = 0

def toss():
flip = random.randint(0, 1)
if flip == 0:
return 'H'
else:
return 'T'

for experimentNumber in range(10000):
# Code that creates a list of 100 'heads' or 'tails' values.
for flipCoin in range(100):
listOf100.append(toss())

# Code that checks if there is a streak of 6 'heads' or 'tails' in a row.
for listItem in range(len(listOf100) - 1):
if listOf100(listItem) == listOf100(listItem + 1):
streak += 1
if streak == 5:
numberOfStreaks += 1
streak = 0
break
else:
streak = 0
listOf100 = ()

print('Chance of streak: %s%%' % (numberOfStreaks / 10000))
``````

My question is, am I correct in setting the condition `if streak == 5`?

My reasoning is that there are 5 pairs to be checked for similarities, if the actual streak is to be 6, for example:
`if listOf100(0) == listOf100(1)`
`if listOf100(1) == listOf100(2)`
`if listOf100(2) == listOf100(3)`
`if listOf100(3) == listOf100(4)`
`if listOf100(4) == listOf100(5)`

So, if all 5 such pairs increase streak with 1, it means that there are 6 list items in a row that are either ‘heads’ or ‘tails’.

Thank you!

exposure – Picture with blue streak

I am trying to figure out why this picture has this blue streaks in this picture.

I know this is taken as a selfie in a cheap non backed mirror ( it was a hand held and the mirror became unglued from the plastic. ) It’s in my bathroom under my cabinet/cupboard. My plant light is in back.

This is not me but I will include some pictures I took to attempt to recreate the original. I also have somewhat of a glowing blue.
Thank you!

Set a winning streak in dice game in Python

Hello everyone. Really, REALLY stuck here. I have written my code below. while
in the loop state, i am trying to set a counter where if
Reach 4 wins, options apply as per code. However I can't work
How to make this work? Can anyone help please? The conscious code is
otherwise cumbersome (and appreciated comments) but I'd rather
retain as close to the original as possible. Thank you!

``````import math
import dice
import random

# def PetalsAroundTheRose

# print introduction
print ("Would you like to play a game?")
print ("The game is...'Petals Around the Rose'. Cool")
print ("and catchy eh? Now, pay attention though as")
print ("the name of the game is important.")
print ("Each round, five dice are rolled and")
print ("You'll be asked for the score. (Hint? The score")
print ("will always be either 'zero' or an even number).")
print ("Your challenge is to deduce how the computer has")
print ("calculated the score.")
print ("You need to input your guess, after which")
print ("You'll learn if you were right. If not, you'll")
print ("be told the correct score & asked to roll again.")
print ("If you can guess correctly four times in a row,")
print ("You'll be declared the winner and receive the")
print ("majestic title of 'Potentate of the Rose'")

print ("")

# Ask user if up for the challenge!
# If no, exit game.
# If yes, roll the dice
play_petals = input("Are you up for the challenge? Enter 'y' for yes or 'n' for no: ")
print ("")
if play_petals == 'n':
print ("Really? Ok, see ya!")
exit()
if play_petals == 'y':
print ("Ok...here comes the first roll!")
else:
print("Sorry, wrong key? Press either y or n to continue please")

# Capture & maintain tally of correct guesses
# Four consecutive correct guesses required
# If incorrect, reset winning streak to zero

# Generate random roll of five dice
# Display resulting dice roll
die1 = random.randint(1,6)
die2 = random.randint(1,6)
die3 = random.randint(1,6)
die4 = random.randint(1,6)
die5 = random.randint(1,6)
result = dice.display_dice(die1, die2, die3, die4, die5)

# Define the roll result in line with rules
# Only include in total if is a 3 or a 5, other results in zero
def roll_result(die1):
if die1 == 1 or die1 == 2 or die1 == 4 or die1 == 6:
die1 = 0
elif die1 == 3:
die1 = 2
elif die1 == 5:
die1 = 4
return die1
def roll_result(die2):
if die2 == 1 or die2 == 2 or die2 == 4 or die2 == 6:
die2 = 0
elif die2 == 3:
die2 = 2
elif die2 == 5:
die2 = 4
return die2
def roll_result(die3):
if die3 == 1 or die3 == 2 or die3 == 4 or die3 == 6:
die3 = 0
elif die3 == 3:
die3 = 2
elif die3 == 5:
die3 = 4
return die3
def roll_result(die4):
if die4 == 1 or die4 == 2 or die4 == 4 or die4 == 6:
die4 = 0
elif die4 == 3:
die4 = 2
elif die4 == 5:
die4 = 4
return die4
def roll_result(die5):
if die5 == 1 or die5 == 2 or die5 == 4 or die5 == 6:
die5 = 0
elif die5 == 3:
die5= 2
elif die5 == 5:
die5 = 4
return die5
a = roll_result(die1)
b = roll_result(die2)
c = roll_result(die3)
d = roll_result(die4)
e = roll_result(die5)
total_roll_result = a + b + c + d + e
# Get players guess for roll
if roll_guess == total_roll_result:
print ("Well done! Correct!")
elif roll_guess % 2 == 0:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
else:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
print ("Remember,the answer will always be an even number")

# "keep playing?" loop
keep_playing = input("keep playing? Enter y or n: ")
print ("")
if keep_playing == 'n':
exit()
if keep_playing == 'y':
print ("Ok...here comes the next roll!")
def win_count():
win_count() == 0
correct == total_roll_result
while keep_playing == 'y':
die1 = random.randint(1,6)
die2 = random.randint(1,6)
die3 = random.randint(1,6)
die4 = random.randint(1,6)
die5 = random.randint(1,6)
result = dice.display_dice(die1, die2, die3, die4, die5)
a = roll_result(die1)
b = roll_result(die2)
c = roll_result(die3)
d = roll_result(die4)
e = roll_result(die5)
total_roll_result = a + b + c + d + e
if roll_guess == total_roll_result:
print ("Well done! Correct!")
elif roll_guess % 2 == 0:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
else:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
print ("Remember,the answer will always be an even number")
while keep_playing == 'y':
def win_count():
win_count() == 0
correct == total_roll_result
while win_count <= 4:
if roll_guess(correct):
win_count += 1
else:
win_count = 0
if win_count == 4:
print ("You keep getting this right!")
stop_playing = input("Do you want to keep playing? Enter y or n ")
if stop_playing == 'n':
exit()
if stop_playing == 'y':
print ("")
print ("Game Summary")
print ("------------")
print ("")
print ("You played X games:")
print ("")
print ("")
print ("Thanks for playing")
exit()
``````

Can Trump extend his streak of luck in the Coronavirus or will all the lies and propaganda finally end?

Yes, because his method of always blaming the messenger finally loses. He blamed the discovery of Russian interference on intelligence agencies, and will blame the growing number of cases of coronavirus on people who perform the tests. That is why it is holding back a wide distribution of test kits. His method is to hide the truth.

He wants that cruise out of SF to remain at sea with his coronavirus patients so that they do not statistically join their total victims here within the US. UU. Is that reasoning crazy, or am I crazy?

The price of Bitcin is in the winning streak! See the exchange of the most powerful Bitmex Bot live in our operating room. – Advertising, Offers.

Visit Crypto Signal for free and get daily profits through a dynamic Bitmex BOT – https://t.me/freebitmexsignals

Bitcoin (BTC) has surpassed the \$ 13,000 price tag and many of the top 20 cryptocurrencies that show double-digit gains on the day.

The original cryptocurrency is on the rise, with a winning streak of eight days to reach the prices last seen in January 2018.

James Harden adds new wrinkles to the 30-point streak

James Harden adds new wrinkles to the 30-point streak

1. James Harden adds new wrinkles to the 30-point streak

James Harden adds new wrinkles to the 30-point streak for state-of-the-art sports, in a burst of 57 points in a victory over the Grizzlies. read more