📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
查看: 3004| 回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

dataquest,CS61A,CS61B

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
运筹小硕一枚,本科没有接触过Python或R,做作业觉得有点吃力,自学一下。还有就是,其实很迷茫以后是找工作还是读博。找工作是数据分析、优化还是供应链。很迷茫,但是下定决心不想一毕业就回国的话,那肯定要做好转码的准备,给自己留条退路。所以不管从哪个角度来说,刷刷题刷刷网课都是极好的。打卡自我监督吧

上一篇:求问黑客马拉松的注意事项
下一篇:一亩三分地团队2019纳新:SDE/DS/UX/PM 各类项目都有!
🔗
 楼主| SherryN9996 2018-10-21 13:36:46 | 只看该作者
全局:
day1 10/20
• ** #exponent

• = #assign

• Numerical values like integers and floats don't require quotation marks, but strings do.

• type() #won't display anything. Instead, it will return the data type as a value, which can be assigned to another variable or displayed using the print() statement
hello = 'Hello'
print(type(hello))

• Make a list:
Variablename = [] #create an empty list, then
list.append() #method to add values to a list object
或者
cities = ["Albuquerque", "Anaheim", "Anchorage", "Arlington", "Atlanta"]

• Unlike functions, methods are called using dot notation (.) on a specific object.

• A list starts at index 0 and goes all the way to one less than the total number of values
crime_rates = [749, 371, 828, 503, 1379]
first_value = crime_rates[0]
second_value = crime_rates[1]
fifth_value = crime_rates[4]

• len() #function returns the length of a list, or the number of elements in that list.

• Slicing:
The value at the starting index and all of the values in between will be returned. The value at the ending index will not.
crime_rates = [749, 371, 828, 503, 1379]
# The following slice selects values at index 2 and 3, but not 4.
two_four = crime_rates[2:4]

ending_index = len(crime_rates)
two_to_end = crime_rates[2:ending_index]

• a = open("story.txt", "r")
##r means read. a doesn't contain the actual content

• f = open("test.txt", "r")
g = f.read()#g contains the actual content

• Splitting:
\n #换行
Albuquerque,749\nAnaheim,371\nAnchorage,828\n
split()#method to turn a string object into a list of strings
sample = "john,plastic,joe"
split_list = sample.split(",")# split_list is a list of _strings_: ["john", "plastic", "joe"]
split_list = sample.split("\n")

• Loop:
cities = ["Austin", "Dallas", "Houston"]
for city in cities:
    print(city)
#注意loop body之前有冒号,loop body前空4个空格

• List of lists
three_rows = ["Albuquerque,749", "Anaheim,371", "Anchorage,828"]
final_list = []
for row in three_rows:
    split_list = row.split(',')
    final_list.append(split_list)
print(final_list)
# the elements in final_list are lists.
Here's what the output looks like: 
[['Albuquerque', '749'], ['Anaheim', '371'], ['Anchorage', '828']]

• # Returns the first list's first element, 'Albuquerque'.
first_list_first_value = final_data[0][0]
# Returns the second list's first element, 'Anaheim'.
second_list_first_value = final_data[1][0]
# Returns the third list's first element, 'Anchorage'.
third_list_first_value = final_data[2][0]
回复

使用道具 举报

🔗
 楼主| SherryN9996 2018-10-22 10:51:59 | 只看该作者
全局:
day 2 10/21 dataquest booleans&challenges 这两节很简单 没有做笔记
print(nested_list[0:5])
numerical_list=[]
name_ssn=[]
for row in nested_list:
    name=row[0]
    ssn=float(row[1])
    name_ssn=[name,ssn] #Create a new list containing these two elements .
    numerical_list.append(name_ssn)
print(numerical_list[0:5])
回复

使用道具 举报

🔗
 楼主| SherryN9996 2018-10-23 12:05:24 | 只看该作者
全局:
day 3 10/22 dataquest list operations,dictionary
        • in
        animals = ["cat", "dog", "rabbit"]
        if "cat" in animals:
            print("Cat found")
       
        animals = ["cat", "dog", "rabbit"]
        cat_found = "cat" in animals
       
         #We can also use the in statement to check whether a keyoccurs in a dictionary
       
        • data = data[1:len(data)]
        #Removing the header value from the list of lists data
• A dictionary is like a list in that it has indexes, but the indexes aren't necessarily sequential numbers. We can create our own indexes with values of any data type, including strings.
• While we initiate a new list with square brackets ([), we create a new dictionary with curly braces ({). We can make an empty dictionary like this:

scores = {}
scores["Tom"] = 70
#we call the index and value key/value pairs. 

students = {
    "Tom": 60,
    "Jim": 70
}
#注意等号,冒号,逗号
#两者相等

• #Add the key Ann and value 85 to the dictionary students.
students['Ann']=85
• We can also use the in statement to check whether a keyoccurs in a dictionary
• weather_counts = {}
for item in weather:
    if item in weather_counts:
        weather_counts[item]=weather_counts[item]+1
    else:
        weather_counts[item]=1
print(weather_counts)
#计算每种天气出现几次,注意else后加冒号,else要和if对齐
回复

使用道具 举报

🔗
tz35 2018-11-20 12:35:44 | 只看该作者
全局:
请教LZ进度如何 dataquest上下来怎么样?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表