跳至主要內容
NYU CS Python 答疑2

Question 1

Extract the data from the file practice138.csv

提取文件 practice 138.csv 中的数据。

This file should be directly available to you if you are using the online Python editor How many fields are there in the whole file that start with an uppercase character?


AI悦创原创...大约 86 分钟NYUNYU UniversityNYUNYU University
NYU – Tandon School of Engineering CS-UY 1114 Final Review

The Story

Professor and Pokémon trainer Katz wants to be the very best that no one ever was. To that end, he has travelled across the land and caught and trained a bunch of Eevees , which have now evolved. His team looks like this at the moment:


AI悦创原创...大约 4 分钟NYUNYU – Tandon School of EngineeringNYUNYU – Tandon School of Engineering
NYU – Tandon School of Engineering True Exam – 16 December 2021
  1. Evaluate this code. What will be printed
class Animal:
    def __init__(self, name, species, age):
        self.name = name
        self.species = species
        self.age = age

    def is_adult(self):
        return self.age > 3

    def is_young(self):
        return self.age < 1

    def __str__(self):
        return "{} ({}, {} years old)".format(self.name, self.species, self.age)

    def __repr__(self):
        return "Animal('{}', '{}', {})".format(self.name, self.species, self.age)

def main():
    cat = Animal("Fluffy", "cat", 2)
    dog = Animal("Rover", "dog", 4)
    bird = Animal("Tweety", "bird", 1)
    fish = Animal("Nemo", "fish", 0.5)

    a = cat.is_adult()
    b = dog.is_young()
    c = repr(bird)
    d = str(fish)
    e = fish.is_adult()
    f = bird.name

    print('It is', b, bird.name, "is young")
    print(b)
    print(c)
    print(bird)
    print(d)
    print(e)
    print(f)

AI悦创原创...大约 3 分钟NYUNYU – Tandon School of EngineeringNYUNYU – Tandon School of Engineering
NYU – Tandon School of Engineering Final Exam – 16 December 2021

Final Exam – 16 December 2021

  1. (15 Points) Provide the value of the variable “var” (use python form to show the appropriate data type, e.g. “str” , [list], etc). Note: following code snippets will not produce errors.

Value of var after code runs


AI悦创原创...大约 13 分钟NYUNYU – Tandon School of EngineeringNYUNYU – Tandon School of Engineering
NYU CS Python 答疑

Question 1

This question asks you to solve a problem by writing a program. If you haven't done so already, open the Python editor by clicking here. Follow the directions carefully and use the result of your program as your answer. Do not submit your program as your answer!

这道题要求你通过编写程序来解决一个问题。如果您还没有这样做,请单击这里打开 Python 编辑器。仔细按照说明,并使用你的程序的结果作为你的答案。不要提交你的程序作为你的答案!


AI悦创原创...大约 10 分钟NYUNYU UniversityNYUNYU University