跳至主要內容
Homework 8

Homework 8

Exercise 1: Sieve of Eratosthenes

Early in the course, we saw a few naive ways to output a list of prime numbers. Although we were able to improve the speed of the search a lot by incorporating a few arithmetic insights, it still took longer than it needed to for somewhat larger numbers.


AI悦创原创...大约 9 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 8

Data analysis

For this lab you'll use dictionaries to collect statistics for a simple data file representing a collection of users. Begin by downloading the starter code and data hereLinks to an external site.


AI悦创原创...大约 3 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 7

Homework 7

Exercise 1: Luhn's algorithm

Luhn’s algorithm, also known as the modulus 10 or mod 10 algorithm, is a checksum formula used to validate a variety of identification numbers, such as credit card numbers and ID numbers. You will write a program called luhn.py that asks for an account number and determines whether or not the number is valid using Luhn’s algorithm. The steps of the algorithm are given below.


AI悦创原创...大约 7 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 7 - Street Craps

Street craps

img

In class we looked at a simple card game implemented using object-oriented programming. For this lab, you'll adapt that structure to create a simple dice game based on the classic signifier of misspent youth: street craps.

The rules of street craps are as follows. The shooter rolls two dice. If the first roll is 2, 3, or 12 the shooter loses. If the first roll is 7 or 11, the shooter wins. If the first roll is anything else, that value becomes the shooter's "point". The shooter continues to roll the dice until either the "point" comes up again, in which case the shooter wins, or until a 7 comes up, in which case the shooter loses.


AI悦创原创...大约 4 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 6

Homework 6

Part 1: Book questions

Create a text file called hw6_book_exercises.txt. Answer 7.7 Exercises 1 through 10 from the textbook.

Part 2: Programming exercises

Programming exercise 1: Triangular number list

This program will revisit the concept of "triangular numbers"Links to an external site. from a previous assignment. You may re-use code from your solution to that assignment if you wish.


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 6

For this lab period, please do the following exercise.

Making a rocket

For this exercise, you'll do a little more ascii art! In this exercise, you'll need to pull some of the functionality out of main() into its own functions.

You'll write a program called make_a_rocket.py that prints out a rocket consisting of a nose cone, a fuselage, and a tail fin structure. The program will take 2 required arguments and one optional argument. The two required arguments are numbers representing the width of the rocket in characters, and the length of the rocket's fuselage in square segments. The third argument will be either left blank (not given) or will be the word "striped". The nose cone and tail structure are composed of * characters. The fuselage is made up of X characters by default. If the striped argument is passed when the program is executed, each segment of the fuselage will be drawn half with Xs and half with _ characters, resulting in a striped appearance.


AI悦创原创...大约 3 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 5

Homework 5

Water Consumption

This week you'll write a program that performs some analysis on actual, real-life data! My friend Brad moved into a new house — one that has a device that monitors how much electricity is used. Once a minute, it records the power usage on each of the electrical circuits in the house. The water comes from a well, and it dawned on him that he could calculate how much water the house is using by looking at the power data.


AI悦创原创...大约 7 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 5

For lab 5, please do the following exercise

Word & character counter

Download the text file from hereLinks to an external site.. You'll write a program called word_count.py that prompts the user for a file name, then prints out counts of words, non-whitespace characters (including punctuation), and alphanumeric characters (letters and numbers, excluding punctuation), like this:


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 4

Part 1: Book questions

Create a text file called hw4_book_exercises.txt. Answer 5.9 Exercises 1 through 5, and 13 from the textbook.

Part 2: Programming exercises

Programming exercise 1: Triangular numbers

Write a program called triangular.py that takes a number as an argument when the program is run and prints out the "triangular number"Links to an external site. of the input number (i.e., the sum of values between 1 and the input number).


AI悦创原创...大约 6 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 4

Programming exercise 1: Drawing a rectangle

For this exercise, you'll use one or more for loops. Write a program called rectangle.py that asks the user for a symbol they would like to use to make a rectangle. Here, the symbol can be any single character (e.g., &, #, +, n, s, 3). Also, ask the user for the rectangle’s width and height. For example, if the user enters + for the symbol, 10 for the width, and 5 for the height, your program should print the following rectangle to the output:


AI悦创原创...大约 4 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 3

Part 1: Book exercises

Create a text file called hw3_book_exercises.txt. Answer 4.14 Exercises questions 1-7 from the book.

Part 2: Expert system

One of the earliest forms of artificial intelligence (AI) were expert systems. An expert system is a system designed to make decisions or arrive at diagnoses based on information it is given. The decisions it makes are based on a sequence of conditionals.


AI悦创原创...大约 2 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 3

For Lab 3, complete each of the following exercises.

Exercise 1: Capitalized vowels

Write a short program called cap_vowels.py that takes a string of input from the user with any capitalization and prints out the string, but with all consonants in lower case and all vowels in upper case. Read about string methods in the Python 3 docsLinks to an external site. and to see a full list of operations you can use on string. Try to do it in the fewest function calls you can.


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 2

Heart Health

Your heart-rate is defined as the number of contractions (i.e. beats) of your heart per minute. (A good place to feel your heart beat is on your neck right under the corner of your jaw. If you press two fingers there, and count the number of beats in a single minute, this gives you an estimate for your heart rate).


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 2

Topics

  1. Basic arithmetic operations and expressions
  2. "Casting" types (converting values from one type to another)

To get started, create a directory called lab02 inside your cs5001 directory.

Programming exercises

  1. Click hereLinks to an external site. to go to Weather Underground for Seattle, WA. This website compiles a variety of climate data such as high and low temperatures, pressure, visibility, precipitation, etc.

    Use the data provided on this website to perform arithmetic computations using the four operators: +, −, ∗, and /. Create a program called weather.py which calculates the following and prints out the results (you can enter the input values into your program by hand):

    • What is the difference between the highest and the lowest temperature values predicted for the 10 day forecast?
    • What is the average temperature at noon predicted for the 10 day forecast?
    • What is the highest temperature predicted for the 10 day forecast, converted from Fahrenheit to Celsius?
  2. Using input you can prompt the user for input on the command line. Write a program called adder.py which takes input from the user in the form of numerical values, and prints out a sentence reporting the sum of the values, like this:


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 1

Create a new directory

Start up Visual Studio Code and open your cs5001 directory. Create a new directory called hw01.

Again, if you navigate to your cs5001 folder on your system, you'll see the newly created folder called hw01 and inside of this new folder will be all of the code your write for this assignment.


AI悦创原创...大约 4 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Quiz

Question 1

Which of the following Python statements will result in the value 3 stored in the variable x?

A. x = 16.0% 3.5

B. x=16%4

C. X=16 /2

D. x=16 // 5

E. x=16 // 3

Question 2


AI悦创原创...大约 2 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Lab 5 Word & character counter

Download the text file from hereLinks to an external site.. You'll write a program called word_count.py that prompts the user for a file name, then prints out counts of words, non-whitespace characters (including punctuation), and alphanumeric characters (letters and numbers, excluding punctuation), like this:


AI悦创原创...大约 5 分钟python 1v1northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导
Homework 3

Part 1: Book exercises

Create a text file called hw3_book_exercises.txt. Answer 4.14 Exercises questions 1-7 from the book.

创建一个名为 hw3_book_exercises.txt 的文本文件。从书中回答4.14练习的问题1-7。

1. Exercises

  1. What possible values can a Boolean expression have?

  2. Where does the term Boolean originate?

  3. What is an integer equivalent to True in Python?

  4. What is the integer equivalent to False in Python?

  5. Is the value -16 interpreted as True or False?

  6. Given the following definitions:

    x, y, z = 3, 5, 7

    evaluate the following Boolean expressions:

    (a) x == 3

    (b) x < y

    (c) x >= y

    (d) x <= y

    (e) x != y - 2

    (f) x < 10

    (g) x >= 0 and x < 10

    (h) x < 0 and x < 10

    (i) x >= 0 and x < 2

    (j) x < 0 or x < 10

    (k) x > 0 or x < 10

    (l) x < 0 or x > 10

  7. Given the following definitions:


AI悦创原创...大约 5 分钟1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导