JavaScript进阶篇 - day-four深入探索

需积分: 5 0 下载量 79 浏览量 更新于2024-12-22 收藏 1KB ZIP 举报
资源摘要信息:"JavaScript编程基础与实践" JavaScript是一门广泛应用于网页开发的编程语言,它能够实现网页内容的动态更新、增强用户交互体验,并且在前后端开发中都扮演着重要的角色。对于初学者来说,理解JavaScript的基础概念和基本语法是学习前端开发的首要任务。 标题中的“day-four”可能意味着这是一系列教程的第四天,通常这样的教程会按照教学计划安排不同的知识点。由于没有具体描述细节,我们可以推测第四天可能会涉及JavaScript的更进阶概念。 描述中的“day-four”与标题相同,没有提供额外信息,因此知识点讲解将基于通用的JavaScript进阶知识。 在标签“JavaScript”中,我们可以提炼出以下知识点: 1. 变量和数据类型:JavaScript中的变量使用var, let或const来声明。数据类型分为基本类型(如number, string, boolean, null, undefined等)和引用类型(如对象object, 数组array, 函数function等)。 2. 控制结构:JavaScript使用条件语句(如if-else, switch)和循环语句(如for, while)来控制代码的执行流程。 3. 函数:函数是JavaScript中的核心概念,可以通过function关键字或者箭头函数(=>)定义,用于执行特定任务。 4. 对象和数组:对象是属性的集合,使用花括号{}来创建;数组是值的有序集合,使用方括号[]来创建。它们都是引用类型,可以包含不同的数据类型。 5. DOM操作:文档对象模型(DOM)是网页的编程接口。通过JavaScript可以访问和修改网页的DOM元素,从而实现动态更新网页内容。 6. 事件处理:JavaScript可以响应用户交互事件(如点击、按键等),通过添加事件监听器来实现。 7. 异步编程:JavaScript支持异步编程模式,如回调函数、Promise对象、async/await语法,这对于处理网络请求、定时任务等非常有用。 8. ES6+特性:ES6(ECMAScript 2015)带来了大量新特性,包括类、模块、箭头函数、let和const声明、解构赋值、剩余参数等等,这些特性大幅提高了JavaScript的开发效率。 描述压缩包子文件的文件名称列表“day-four-master”,暗示这是一个包含多个文件的项目目录,其中“day-four-master”很可能是整个教程项目的根目录名称。一个典型的项目结构可能包括如下文件和目录: - src/:源代码目录,包含JavaScript文件,如index.js, app.js等。 - dist/:构建后输出的文件目录,通常存放打包后的代码。 - assets/:静态资源目录,存放图片、样式表、字体等。 - index.html:项目的入口HTML文件。 - package.json:包含项目的配置信息,如依赖、脚本等。 - .gitignore:指示Git版本控制系统忽略特定文件的配置文件。 - README.md:项目的说明文档。 了解和掌握这些知识点,可以帮助前端开发者更好地使用JavaScript进行网页开发,实现更加丰富和动态的用户界面。在第四天的学习中,学生可能会学习到如何综合使用这些知识点来构建更加复杂的应用程序。

import pandas as pd df = pd.read_csv('stock_data.csv') df['four_days_increase'] = df['close'].rolling(window=4).apply(lambda x: all(x[i] < x[i+1] for i in range(3))) * 1 df['three_days_decrease'] = df['close'].rolling(window=3).apply(lambda x: all(x[i] > x[i+1] for i in range(2))) * 1 capital = 1000000 max_stock_per_day = 10 max_stock_value = 100000 start_date = '2020-01-01' end_date = '2023-01-01' df = df[(df['date'] >= start_date) & (df['date'] < end_date)] df = df.reset_index(drop=True) hold_stock = [] for i, row in df.iterrows(): if len(hold_stock) > 0: sell_stock = [] for stock in hold_stock: if i - stock['buy_day'] >= 3: capital += stock['buy_price'] * stock['buy_qty'] * (1 - 0.002) sell_stock.append(stock) hold_stock = [stock for stock in hold_stock if stock not in sell_stock] df_today = df.loc[i:i+3] if i + 3 >= len(df): break if all(df_today['four_days_increase']) and all(df_today['three_days_decrease'].iloc[1:]): available_capital = capital available_stock = max_stock_per_day available_value = max_stock_value for j, stock_row in df_today.iterrows(): if available_capital > 0 and available_stock > 0 and available_value > 0: buy_qty = min(int(available_capital / (stock_row['close'] * 1.002)), available_stock, int(available_value / (stock_row['close'] * 1.002))) if buy_qty > 0: hold_stock.append({'buy_day': i, 'buy_price': stock_row['close'], 'buy_qty': buy_qty}) available_capital -= stock_row['close'] * buy_qty * 1.002 available_stock -= 1 available_value -= stock_row['close'] * buy_qty * 1.002 print('Final capital:', capital)让上述代码在jupyter里不报错

2023-06-02 上传

马丁路德金的"I have a dream"节选存放在"freedom.txt"中: I have a dream that one day this nation will rise up, live up to the true meaning of its creed: “We hold these truths to be self-evident; that all men are created equal.” I have a dream that one day on the red hills of Georgia the sons of former slaves and the sons of former slave-owners will be able to sit down together at the table of br otherhood. I have a dream that one day even the state of Mississippi, a state sweltering with th e heat of injustice, sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice. I have a dream that my four children will one day live in a nation where they will no t be judged by the color if their skin but by the content of their character. I have a dream today. I have a dream that one day down in Alabama with its governor having his lips drippin g with the words of interposition and nullification, one day right down in Alabama li ttle black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. I have a dream today. I have a dream that one day every valley shall be exalted, every hill and mountain sh all be made low, the rough places will be made plain, and the crooked places will be made straight, and the glory of the Lord shall be revealed, and all flesh shall see i t together. 编程实现词汇表,计算每一个单词出现的次数,大小写不区分,输出到"dic.txt" 文件保存。

2023-06-01 上传