Answer:
I'm looking for this one too
Answer:
import simplegui
import random
# global constants
WIDTH = 600
HEIGHT = 400
PARTICLE_RADIUS = 5
COLOR_LIST = ["Red", "Green", "Blue", "White"]
DIRECTION_LIST = [[1,0], [0, 1], [-1, 0], [0, -1]]
# definition of Particle class
class Particle:
# initializer for particles
def __init__(self, position, color):
self.position = position
self.color = color
# method that updates position of a particle
def move(self, offset):
self.position[0] += offset[0]
self.position[1] += offset[1]
# draw method for particles
def draw(self, canvas):
canvas.draw_circle(self.position, PARTICLE_RADIUS, 1, self.color, self.color)
# string method for particles
def __str__(self):
return "Particle with position = " + str(self.position) + " and color = " + self.color
# draw handler
def draw(canvas):
for p in particle_list:
p.move(random.choice(DIRECTION_LIST))
for p in particle_list:
p.draw(canvas)
# create frame and register draw handler
frame = simplegui.create_frame("Particle simulator", WIDTH, HEIGHT)
frame.set_draw_handler(draw)
# create a list of particles
particle_list = []
for i in range(100):
p = Particle([WIDTH / 2, HEIGHT / 2], random.choice(COLOR_LIST))
particle_list.append(p)
# start frame
frame.start()
Explanation:
this worked for me, sorry if its to late. let me know if anything is wrong
You wrote a program to allow the user to guess a number. Complete the code to get a number from the user.
# Get a guess from the user and update the number of guesses.
guess =
("Guess an integer from 1 to 10: ")
NEED HELP FAST
Answer:
import random
number = random.randrange(1, 10)
is_guess = 'y'
while is_guess == 'y':
try:
guess = int(input("Guess an integer number between 1 and 10: "))
if guess < 1 or guess >10:
print("You have exceeded the guessing range, try again")
continue
elif guess == number:
print("Congrats! You guessed right.")
else:
print("Sorry, you guessed wrong")
except ValueError:
print("Your guess must be an integer number.")
is_guess = input("Do you want to try again y/n ? ")
Explanation:
The random module of the python programming language is used to randomly select an integer value from a range of numbers. The guess variable value is a user input of an integer number.
If the guess variable is equal to the random number, then the program prints a congratulatory message. The program is no constant loop so long as the is_guess variable is equal to 'y'.
The try-except statement is used to detect the value error of the guess variable.
Answer:
input
Explanation:
For this exercise, we are going to take a look at an alternate Calculator class, but this one is broken. There are several scope issues in the calculator class that are preventing it from running. Your task is to fix the Calculator class so that it runs and prints out the correct results. The CalculatorTester is completed and should function correctly once you fix the Calculator class.
public class Calculator {
private int total;
private int value;
public Calculator(int startingValue){
int total = startingValue;
value = 0;
}
public int add(int value){
int total = total + value;
return total;
}
/**
* Adds the instance variable value to the total
*/
public int add(){
int total += value;
return total;
}
public int multiple(int value){
int total *= value;
return total;
}
public void setValue(int value){
value = value;
}
public int getValue(){
return value;
}
}
Answer:
public class Calculator {
private int total;
private int value;
public Calculator(int startingValue){
// no need to create a new total variable here, we need to set to the our instance total variable
total = startingValue;
value = 0;
}
public int add(int value){
//same here, no need to create a new total variable. We need to add the value to the instance total variable
total = total + value;
return total;
}
/**
* Adds the instance variable value to the total
*/
public int add(){
// no need to create a new total variable. We need to add the value to the instance total variable
total += value;
return total;
}
public int multiple(int value){
// no need to create a new total variable. We need to multiply the instance total variable by value.
total *= value;
return total;
}
//We need to specify which value refers to which variable. Otherwise, there will be confusion. Since you declare the parameter as value, you need to put this keyword before the instance variable so that it will be distinguishable by the compiler.
public void setValue(int value){
this.value = value;
}
public int getValue(){
return value;
}
}
Explanation:
I fixed the errors. You may see them as comments in the code
click it to paste the content of clipboard
Ctrl + V
It is used for paste function.
Analytical Engine was designed in
Answer:
1838
Explanation:
Analytical Engine was designed in 1838. The designer is Charles Babbage, who was an English mathematician and widely known for his innovation in the engineering world. He is often considered to be the father of computers.
Following his inability to finish the creation of Difference Engine, Charles Babbage would later when ahead to conceived the Analytical Machine in 1834
He eventually finished the design of an Analytical Machine by 1838.
Answer:
Charles Babbage
Explanation:
Just did test
Please program this in Python.
Create a list of your favorite 4 movies. Print out the 0th element in the list. Now set the 0th element to be “Star Wars” and try printing it out again.
lst = ["Star Wars", "Movie 2", "Movie 3", "Movie 4"]
print(lst[0])
I wrote my code in python 3.8. Best of luck
Another technique that makes use of the colon slicing technique to directly refer to element places is list slicing. Use a blank value before the first colon to access the first element, then use len() with -1 as the input to access the last element.
What is the 0th element in the list?The element of the current ArrayList object at the provided index is returned by the get() function of the ArrayList class, which accepts an integer indicating the index value.
As a result, if you supply 0 or list to this method, you can obtain the first element of the current ArrayList.
Use a for loop with range (0, N) to get the first N members of a list. Then, make a new empty list and append the elements of the source list to the new list within the for loop. Range(0, N) iterates in steps of 1 from 0 to N-1. N is not comprised.
Therefore,lst = ["Star Wars", "Movie 2", "Movie 3", "Movie 4"] print(lst[0]).
Learn more about element here:
https://brainly.com/question/19312961
#SPJ2
Write a Python function that takes a positive integer N and returns the factorial of N, i.e., N! The factorial of N, denoted N!, is the product of the integers from 1 to N. (1 Point)
Answer:
The python function is as follows:
def fact(N):
factorial = 1
for i in range(1,N+1):
factorial = factorial * i
return(factorial)
Explanation:
This line defines the function
def fact(N):
This line initializes the product of 1 to N to 1
factorial = 1
This line iterates through 1 to N
for i in range(1,N+1):
This line calculates the product of 1 to N i.e. factorial
factorial = factorial * i
This line returns the factorial
return(factorial)
Some commands listed in a menu cannot be selected.
True or False
Answer:
Explanation:
it is true
Identify the symbol. please help!!
Explanation:
counter bore
Answer:
Diameter
Explanation:
On technical literature or drawings, it could be a symbol to mean diameter.
explain why it is important for you to understand and describe the basic internal and external components of a computer in the work place
Answer:
you go to edit
Explanation:
There's a chupacabra that looks like a mixed alligator , gecko it looks' like that but if you try harming it will it eat you "look up chupacabra only don't try looking up if it eats meat because that thing is a legendary animal and barely haves answers and has been cured alot and lives in the folklore mostly like the woods" it looks scary and cool the same time but some people said it has been instinct but it isn't it is spanish "which is puerto rican" lives in the united states, and mexico.. ( does it eat meat ) hasn't been seen around but you'll see a picture of it..
Answer:
wait. is this even a question or is it just informing us?
Explanation:
either way it is cool
ANSWER ASAP PLEASE Question #4
Fill in the Blank
Fill in the blank to complete the sentence.
_____ is used to store and process data over the Internet using computers that are not located at tthe users site.
Answer:
A cookie.
Explanation:
Click the crown at the top of this answer if this helped ;)
Which HTML tag is used to add an ordered list to a web page?
Answer:
<ol> Defines an ordered list
Answer:
<ol>
Explanation:
What is a free and compatible alternative to the Microsoft Office Suite (word processing, spreadsheets, and calendars)?
WordPad
Open Office
Notepad
Lotus Notes
Answer:
Open Office
Explanation:
Open Office may be regarded as an open source productivity tool which allows users to enjoy the ability to create and edit documents similar to Microsoft Word, create spreadsheet files and documents similar to Microsoft excel and Presentation tool similar to Microsoft PowerPoint. With the open source category of open office, it means it is a free software whereby users can enjoy these tools without having to purchase any user license. The other tools in the option such as Notepad, Lotus note do not posses all these functionality.
. Write a short Python function that takes a sequence of integer values and determines if there is a distinct pair of numbers in the sequence whose product is odd. (1 Point)
Answer:
Explanation:
The following code is written in Python and like requested takes a function called odd_number that takes a list of integers as a parameter. It then loops through the list two times, each time calculating the product of the two numbers and returning Yes if the product is an odd number while also including the two numbers from the list that make that product. If there is no odd product in the list the function simply returns No
def odd_product(my_list):
for num1 in range(len(my_list)):
for num2 in range(len(my_list)):
if num1 == num2:
pass
else:
product = my_list.__getitem__(num1) * my_list.__getitem__(num2)
if (product % 2) != 0:
return "Yes, " + str(my_list.__getitem__(num1)) + " and " + str(my_list.__getitem__(num2))
return "No"