Answer to Question #297474 in Python for Ram
Number Game
A group of people are playing a game.They are standing and each carring a card with a number on it.These numbers in the list A. A random number S iis selected.
Find out the new list of numbers after
- S people were removed from the left.
- S people were removed from the right.
Sample Input1
1,2,3
1
Sample Output1
2 3
1 2
test_list = [1,2,3]
print["Original list is : " + str[test_list]]
test_list.pop[0]
test_list.pop[-1]
print["Modified list is : " + str[test_list]]
Learn more about our help with Assignments: Python
import random
print['Enter numbers in the list A [sep. ","]: ', end='']
A = input[].split[',']
# if need manual enter random number S
# print['Enter random number S: ', end='']
# S = int[input[]]
S = random.randint[1, len[A]-1]
print[f'Random number S: {S}']
for i in range[S, len[A]]:
print[A[i], end=' ']
print[]
for i in range[0, len[A]-S]:
print[A[i], end=' ']
import numpy as np
print['']
print["Enter two numbers, low then high."]
l = int[input["low = "]]
h = int[input["high = "]]
def binarySearch [arr, l, r, num]:
if r >= l:
mid = l + [r - l] // 2
print["Is your number Less than, Greater than, or Equal to {0}?".format[arr[mid]]]
while True:
x = str[input["Type 'L', 'G' or 'E':"]]
if x in ['L', 'G', 'E', 'l', 'g', 'e']:
break
print['']
if x == 'E' or x == 'e':
num = num + 1
if num == 1:
print["I found your number in 1 guess."]
else :
print["Your number is {0}. I found it in {1} guesses.".format[arr[mid], num]]
elif x == 'L' or x == 'l':
num = num + 1
return binarySearch[arr, l, mid-1, num]
else:
num = num + 1
return binarySearch[arr, mid + 1, r, num]
else:
print["Your answers have not been consistent."]
while l>h:
print['']
print["Please enter the smaller followed by the larger number."]
l = int[input["low = "]]
h = int[input["high = "]]
print['']
print["Think of a number in the range {0} to {1}.".format[l, h]]
print['']
if l == h:
print["Your number is {0}. I found it in 0 guesses.".format[l]]
else :
arr = np.arange[l+1, h]
binarySearch[arr, 0, len[arr]-1, 0]
class ListNode:
def __init__[self, data, priority]:
self.data = data
self.priority = priority
self.next = None Continue reading →
files=["in_abc10.txt","in_abc100.txt"]
outFiles=["out_abc10a.txt","out_abc100a.txt"]
finalOutputFile=["out10b.txt","out100b.txt"] Continue reading →
{
"cells": [
{
"cell_type": "code",
"execution_count": 195,
"metadata": {},
"outputs": [
{ Continue reading →
from numpy import random
def get_rain[]:
if random.rand[] < rain_chance:
return 0
return max[0, random.normal[rain_mean, rain_std, size=[1, 1]][0][0]] Continue reading →
#!/bin/python3
“””
Explain how your pseudo random numbers are produced.
– The pseudo random numbers without seed value. Will be take the nanosecond on posis system. Then move to text file base on position. So it will work.
– The pseudo rando number with seed value. Will be move to file with this position. That’s
mean the random will be the same
“”” Continue reading →
#include
#include
#include
#include
/* Stores parameters that specify how to the program should behave. * Continue reading →
import numpy as np
print['']
print["Enter two numbers, low then high."]
l = int[input["low = "]]
h = int[input["high = "]]
Continue reading →
from turtle import *
import random
if __name__ == ‘__main__’:
number_coins = int[input[‘Enter a number of coins: ‘]] Continue reading →