Exercise 4: Variables And Names

cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
print "There are", cars, "cars available."print "There are only", drivers, "drivers available."print "There will be", cars_not_driven, "empty cars today."print "We can transport", carpool_capacity, "people today."print "We have", passengers, "to carpool today."print "We need to put about", average_passengers_per_car, "in each car."

起名规则很重要。

变量,首字母小写,其余大写。

函数,均小写,单词间加连线符。

时间: 2024-08-07 00:11:47

Exercise 4: Variables And Names的相关文章

Python Index

Table Of ContentsThe Hard Way Is EasierExercise 0: The SetupExercise 1: A Good First ProgramExercise 2: Comments And Pound CharactersExercise 3: Numbers And MathExercise 4: Variables And NamesExercise 5: More Variables And PrintingExercise 6: Strings

pycharm的模版修改

原文地址:http://www.jetbrains.com/help/pycharm/creating-and-editing-file-templates.html#d600783e347 pycharm 修改新建文件时的头部模板 默认为__author__='...'    [省略号是默认你的计算机名] 修改这个作者名的步骤: 依次点击:File->Settings->Editor->File and Code Templete 点击右侧Templates选项卡,会有一些格式文件新建

Random Forest Classification of Mushrooms

There is a plethora of classification algorithms available to people who have a bit of coding experience and a set of data. A common machine learning method is the random forest, which is a good place to start. This is a use case in R of the randomFo

Uva 110 - Meta-Loopless Sorts(!循环,回溯!)

题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=46  Meta-Loopless Sorts  Background Sorting holds an important place in computer science. Analyzing and implementing various so

php.in

1 [PHP] 2 3 ;;;;;;;;;;; 4 ; WARNING ; 5 ;;;;;;;;;;; 6 ; This is the default settings file for new PHP installations. 7 ; By default, PHP installs itself with a configuration suitable for 8 ; development purposes, and *NOT* for production purposes. 9

OPENVPN搭建与配置

Content-type: text/html; charset=UTF-8 openvpn Section: Maintenance Commands (8)Updated: 17 November 2008Index Return to Main Contents NAME openvpn - secure IP tunnel daemon. SYNOPSIS openvpn [ options ... ] INTRODUCTION OpenVPN is an open source VPN

pycharm 修改新建文件时的头部模板(默认为__author__='...')

pycharm 修改新建文件时的头部模板 默认为__author__='...'    [省略号是默认你的计算机名] 修改这个作者名的步骤: 依次点击:File->Settings->Editor->File and Code Templete 点击右侧Templates选项卡,会有一些格式文件新建时的模板 在这里可以修改这些默认模板 以修改Python Script为例: 默认为: __author__ = '$USER' 把 '$USER' 换成你想要的作者名,也可以直接将这一句删掉

【ruby】ruby基础知识

Install Ruby(安装) For windows you can download Ruby from http://rubyforge.org/frs/?group_id=167 for Linux tryhttp://www.rpmfind.net. Our first program(从此开始) Enter the following into the file, "test.rb". ? 1 puts "Howdy!" At the C: promp

java基础学习----String

关于String类经常出现的面试题: 问题1: String s1 = “abc”; String s2 = “abc”; System.out.println(s1 == s2); 结果:true 问题2: String s1 = new String(“abc”); String s2 = new String(“abc”); System.out.println(s1 == s2); 结果:false 问题3: String s1 = “abc”; String s2 = “a”; Str