An Introduction to Programming, Using Python. By David Schneider
Chapter 6.2, Problem 10
Using Python, write lines of code to carry out the stated task. Assume that the random module has been imported.
Perfect Square Display a perfect square integer between 1 and 10,000 (inclusive) selected at random.
#!/usr/bin/python
import random
def display():
found = 0
while found == 0:
x =
random.randint(1,10000)
for i in the
range(1,x/2):
if x == i * i :
print "Perfect Square",x
found = 1
An Introduction to Programming, Using Python. By David Schneider Chapter 6.2, Problem 10 Using Python, write...
An Introduction to Programming, Using Python. By David Schneider Chapter 6.1, Number 30 State Capitals Assume that the list stateCapitals contains the names of the 50 state capitals. Write a robust code segment that requests the name of a capital and removes it from the list. Using Python Enter a state capital to delete: Chicago Not a state capital. Enter a state capital to delete: Springfield Capital deleted.
This is for programming using Python with the JES software. Please write the code with the proper indentation. Thanks! Problem 1: Write a function that takes 2 arguments (integer or float) and computes the sum, difference, product, and quotient of the arguments. Once you calculate the values you should print out statements telling the user what arguments we used to compute the values and what the result of each calculation (your function should produce 5 lines of output in the...
This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...
Hello, I'm having trouble completing this program in less than four lines using MIPS programming language, we are required to fill in the missing code as indicated (via comments). IMPORTANT: As indicated in the program's comments: ⇒ Write no more than certain number of lines of code as indicated. (One instruction per line, and there will be penalty if your code consumes more lines.) ⇒ Code MUST use only instructions that are allowed i.e., only bit manipulating instructions: (ANDing, ORing,...
CPT 180 Chapter 2 Assignment 3 Directions Using the following guidelines, create a python program. 1. Create a program named printRandomNumbers that gets input from the user and then produces a list of random numbers. 2. Import the random module 3. Add three comment lines at the top of the program that contain: a. Program Name b. Program Description c. Programmer's Name (You) 4. Prompt the user for the following: a. Number of random numbers required b. Lower limit of...
Intro to Programming and Logic (chapter 5): Python 2 - Conditionals and Recursion: Write a program that will simulate a roulette wheel. The pockets on a roulette wheel are different colors. There are 36 pockets – numbered 0 to 35. Pocket 0 and 18 are green. For pockets 1 – 8, the even numbers are black and the odd numbers are red. For pockets 9 – 17, the even numbers are red and the odd numbers are black. For pockets...
Python Programming Chapter 5 Programming Exercise Dinner Selection Program (60 points total) Pseudocode (10 points) As the family cook, you know that the toughest question of the day is "What's for dinner?" You For decide to write a program to help you do days of meal planning for the entree, side and dessert. You will need to use random numbers and functions to complete the project. What's Dinner? • • • Start with a pseudocode (10 points). Write the pseudocode...
Implement the following problem as a self-contained python module. Write a program that continually prompts the user for positive integer values and stores them in a list. You should stop prompting when the user enters a negative integer value. When the user is done entering values, you should print the list of integers they have provided in sorted order. You should then compute the mean and standard deviation of the values in the list. Recall that the mean is just...
Java programming The purpose of this problem is to practice using a generic Urn class. NOTE: Refer to the code for the ArrayStack class from Chapter 12. Use that code as a starting point to create the Urn class, modifying it to remove the methods in the ArrayStack class (push, pop, etc) then add the methods described below. Also change the variable names to reflect the new class. For example the array name should NOT be stack, instead it should...
Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...