jupyter notebook for python (二)
标签: python jupyter notebook python string and interger
(一)
字符串(string):
A String is a common type of data, used in programming, consisting of a sequence of 1 or more characters.
- A String is a sequence of characters (aka: a string of characters)
- Character examples:
A, B, C, a, b, c, 1, 2, 3, !, &
- Character examples:
- A String in python is contained in quotes, single(') or double(")
- String examples: "ABC", 'Joana Dias', 'I have 2 pet cats.', "item #3 cost $3.29 USD"
Note: the quotes containing a string must come in matched pairs
"Hello"or'Hello'are correctly formatted strings"Hello'is incorrectly formatted starting with double " and ending with single ' python needs a matching quote to know where the string ends
- String examples: "ABC", 'Joana Dias', 'I have 2 pet cats.', "item #3 cost $3.29 USD"
示例图:

(二)
整数型(Integers):
#A integers is another type:
- whole numbers such as
-2, -1, 0, 1, 2, 3are Integers - Integers are not placed in quotes
A String can contain any character, this includes letters, spaces, punctuation, number digits and formatting. In a string with digits ("123") the digits are text images rather than representations of numeric values.
remember a line of python code starting with the pound or hash symbol (#*) indicates a *comment
comments are for humans to read and are not run by computers
示例图:

(三)
赋值:
Variables & Storing Strings in Variables:

单词翻译:


总结:我就把它当成一个变量,然后被赋值,打印输出的结果一样。
详情:
Variables are named containers
Computer programs often create storage for things that are used in repeated processing like item_price, student_name, stock_symbol. In python a variable is a type of object that can be addressed by name to access the assigned contents.
Name a variable staring with a letter or underscore "_"
There are different styles for creating variables this course uses lowercase descriptive names connected by underscores:
- item_price
- student_name
- stock_symbol
descriptive names reduce the need for comments in the code and make it easier to share code or read code written long ago
Variables can hold strings
once a variable is assigned:
current_msg = "I am a string"
a python program can refer to the variable, current_msg, in code
so that current_msg, can be used like the string value ("I am a string") which it stores
Variable reassignment
We can reassign a variable, changing the contents. current_msg = "new current message"
Variables can be used in place of literals
If we initialize current_msg = "new current message" then
the literal string "new current message" and the variable current_msg are the same when used in code
(四)
(变量可以重复使用,并被覆盖)
Data types in variables:
实例图:
(图中的任务只是改写例子的名字就ok了)

详情:
variables can be initialized with different data types. Below we see item_price is a decimal(aka - float) and student_name is string
item_price = 10.25 #item_price initialized as a numeric value (no quotes)
student_name ="Dias, Joana" #student_name initialized as a string
license_plate = "123A" #license_plate initialized as a string
Variables can start initialized as an Integer number data type
x = 22here the Integer
22value was assigned to the variablex
The type of data a variable holds can be changed,
Python variables can change the type of data a variable holds
x = 22 x = "I am a string"
x changed type from Integer x = 22 to string x = "I am a string"
Best Practice: Friendly Names Friendly name examples, ( item_price, student_name,license_plate), were used above.
Variables help us to write code that can be used repeatedly
A personalized letter can be sent to every student with individual names by using a name in a variable. Let's start with printing a name based on string variable.
Create a variable, name, at the top of the next cell. Assign a string value to name.
Remember to use the quotes for string values
example:
name = "Joana Dias"
print(name)
翻译:

智能推荐
搭建Jupyter Notebook环境(二)
@Author : By Runsen 搭建Jupyter Notebook环境(二) 文章目录 1、Jupyter notebook历史 2 、环境搭建 3、 conda常见命令 4、虚拟环境搭建 5、 修改jupyter notebook的打开路径 6、 pip 和conda的区别 1、Jupyter notebook历史 Jupyter 创始人 Fernando Pérez 的...
Python学习之路_jupyter notebook
# Anscombe’s quartet Anscombe’s quartet comprises of four datasets, and is rather famous. Why? You’ll find out in this exercise. .dataframe tbody tr th:only-of-type { vertical-align:...
python Jupyter Notebook2
参考Link: (3)机器学习新手必看:Jupyter Notebook入门指南 https://blog.csdn.net/guleileo/article/details/80490921 (4)Windows下的Jupyter Notebook 安装与自定义启动(图文详解) https://www.cnblogs.com/zlslch/p/6984403.html Jupyter Noteb...
Python教程:Jupyter Notebook入门
Jupyter Notebooks使您可以将代码,注释,多媒体和可视化组合到一个交互式文档中,该文档可以共享,重复使用和重新处理。 Jupyter Notebook最初是为用Python,R和Julia编写的数据科学应用程序而开发的,它以各种方式对各种项目都有用。 您可以使用Jupyter Notebook与第三方共享Python代码及其输出,通过实时交互反馈运行代码,或者系统地跟踪和记录工作进度...
猜你喜欢
python学习利器Jupyter Notebook
一、什么是Jupyter Notebook? 简介 Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果。 Jupyter Notebook地址: https://jupyter-notebook.readthedocs.io/en/stable/ 到底什么是 Jupyter Notebook?按照 Jupyter 创始人 ...
Python学习使用--Jupyter NoteBook
文章目录 安装与运行 快捷键 默认地址 查看默认地址 其他使用技巧 安装与运行 可以使用pip直接安装 pip有问题的请参考文档 pip的使用和命令以及错误解决 运行命令 在cmd中直接输入 Jupyter NoteBook 运行完之后会自动在浏览器中展示 快捷键 打开之后为: 需要和esc键联动 需要和enter键联动 默认地址 查看默认地址 在运行起来的项目中新建运行 输入命令 在cmd中运行...
《Python数据分析》第二版.第二章.[学习笔记][Jupyter notebook]
第2章 Python语法基础,IPython和Jupyter Notebooks 2.2 IPython 基础 1. 变量前后使⽤问号?,可以显示对象的信息 2. ??会显示函数的源码 3. %run 运行.py 文件 4. %load 将脚本导⼊到 ⼀个代码格中 5. Ctrl-C 中断运⾏的代码 6. %paste 可以直接运⾏剪贴板中的代码 7. %cpaste可以粘贴任意多的代码再运⾏。如...
Python·Jupyter Notebook各种使用方法
Jupyter Notebook安装的官方网站 安装Jupyter Notebook的先决条件:已经安装了python(python 2.7 或者是python3) 具体的安装方法: 官方建议利用Anaconda安装Jupyter 安装完成Anaconda后,如果该Anaconda并不自带Jupyter Noterbook,那么,打开cmd,输入:conda install jupyter &nb...
冒泡排序,及改进方式,性能优化400%>>>附图解加源码
首先源码附上,源码中带有注释,看不懂没关系,源码后面附带图解,最后附上代码效率提升图 源码如下: 方案一:其实实现很简单,两层循环,每次内层迭代出最大的一个值,将其放入数组最后一个位置,外层循环的末端便往前移一位。其原理如下图 方案一代码块: 方案二:优化改进 仔细观察上面的图,我们不难发现当迭代到图下这样的情况时,其实已经全排序好了,但是我们还是需要对它进行1,2,3,4,5,6的迭代,这些情况...
