Solve it by Python( Random library )Please easy code for beginner to understand, please The girl between home and market, taking every step randomly in one direction. Write a function that will simulate her movement. Its parameters will be the distance between house and market and the number of steps to her ( the maximum length of the simulation). the code finishes when the girl arrives house or the market, or after the number of steps has been exhausted.
>>>girl_way(10, 100)
home . . . . . * . . . . market
home . . . . * . . . . . market
home . . . * . . . . . . market
home . . . . * . . . . . market
home . . . * . . . . . . market
home . . . * . . . . . . market
home . . * . . . . . . . market
home * . . . . . . . . market
Ended in the home again!
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
If you are satisfied with the solution, please rate the answer.
Thank You !
===========================================================================
import random
def girl_way(steps, distance):
distance=distance//20 # scaling 20:1 ratio
#initally the girl is equi distance from both places
distance_from_home = distance
distance_from_market = distance
print('home{}*{}market'.format('.'*distance_from_home,'.'*distance_from_market))
for step in range(steps):
roll = random.randint(0,1)# geenerate either 0 for 1
if roll==0:
distance_from_home-=1
distance_from_market+=1
else:
distance_from_market-=1
distance_from_home+=1
print('home{}*{}market'.format('.' * distance_from_home, '.' * distance_from_market))
if distance_from_home==0:
print('Ended in the home again!')
break
elif distance_from_market==0:
print('Ended in the market again!')
break
if distance_from_market!=0 and distance_from_home!=0:
print('Didnt reached either market or home!')
girl_way(10, 100)
=======================================================================


Solve it by Python( Random library )Please easy code for beginner to understand, please The girl...
Python code
You will need to make use of the random library for this homework. It is pretty simple to use. You can use the following methods: random.choice(list) returns a single item from the list, tuple or string at random. random.sample(list.o - returns a new list of n items randomly chosen from the list, tuple or string random shufflellist)randomly reorders all of the items in the list and changes the list itself. The list must be a mutable object so...
PYTHON CODE ONLY PLEASE, AND COMMENT IN SCRIPT TO SHOW
STEPS (post copy-ready text code, and also a screenshot of code
running)
You work for an on-line game site. Your job is to develop a program that accepts a user name and password. Write a Python script that prompts users for a user name and password. a. The user name should be at least 6 characters long and is stored in a list such that it 1. can't be used...
C++
please use only easy code and stdio.h because im just a
beginner
Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...
python code( using functions please)! Rules of the game: - This game requires a dice. The goal of the game is to collect the correct number of coins to create a dollar. Players take coins based on a roll of the dice. The numbers on the dice correlate to the coin values as follows: 1—penny 2—nickel 3—dime 4—quarter 5— ( pick a random card from 1 to 4): o 1 = penny o 2 =...
Please write python code and please answer all parts and
separate them into their parts, thank you.
Given the sequence:
with the initial condition Xo chosen in the interval [0,1], and "a" is a given parameter between 0 and4 This sequence is a simple model to describe how a population (or civilization) evolves in a closed system with a finite amount of resources. The parameter "a" describes the rate of development and expansion of the civilization. The population is described...
Please help as it is very important task for me please write in Python code and divide this into function and write comments for it 1. Ask the player’s name and welcome them to the game using their name. 2. Ask the player what is par for this game (number between 3-5 inclusive) 3. Ask the player what the distance to the hole for this game is (whole number between 195 and 250 inclusive) 4. Show the game menu: (I)nstructions...
please use python thanks will rate!!
x + Run C Code Validate Implement the function step_random_walk_20(x_coords, Y_coords) below, which should take two arrays of equal length containing the x-andy- coordinates for some number of particles. We'll use a very simple random walk algorithm • For each particle, choose a random angle between 0 and 2 • The particle moves by 1 unit of distance in the direction given by d.o. It is displaced by (Ax, Ay) (cos, sino). We'll do...
Python. Just work in the def sierpinski. No output needed. Will
give thumbs up for any attempt beginning this code.
Your task is to implement this algorithm in Python, returning a random collection of inum-100, 000 points. You should then plot the points to see the structure. Please complete the following function: def sierpinski (po, v, f, inum) The four arguments are ·po the initial point. You may assume this is the origin, i.e., po = [0, 0] . v:...
PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList: def __init__(self): self.__head = None self.__tail = None self.__size = 0 def insert(self, i, data): if self.isEmpty(): self.__head = listNode(data) self.__tail = self.__head elif i <= 0: self.__head = listNode(data, self.__head) elif i >= self.__size: self.__tail.setNext(listNode(data)) self.__tail = self.__tail.getNext() else: current = self.__getIthNode(i - 1) current.setNext(listNode(data,...
PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...