Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Snippets The following snippets of code are fully functional snippets. They can be placed in a python source file (a file ending in .py) and

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Snippets The following snippets of code are fully functional snippets. They can be placed in a python source file (a file ending in .py) and then executed. First predict what you think the output will be. Then paste the code into a python file, try it, and record the actual result. Write your own Write code snippets to do the following. You should write these in a Python editor and test them out as you go. When they work, copy and paste your final code snippet here. \begin{tabular}{|l|l|} \hline Specification 4 Define a function called coin flip, where: \\ & Therearenoparametersgiven-Thereisnothingreturnedfromthefunction-Thereisasideeffectofprintingtothescreeneither"Coinflipisheads."or"Coinflipistails."Oodothis:Generatearandomnumber(0or1).Ifthenumberis0,printoneofthestatements.Ifthenumberis1,printtheotherstatement. \\ \\ \hline Code 4 & \\ \hline \end{tabular} Answer the following questions then submit the assignment. 1. Where should import statements be placed in a program? 2. In code 2 , what would happen if we changed the value inside random.randrange() from 4 to 5 ? i.e. What would happen if the first line in the hogwarts() function was 'house = random.randrange(5)'? 3. Write the function coin_flip described in Specification 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions