当前位置: 首页 > news >正文

【ATBS with Python】QA Chap1 Python Basics

Automate The Boring Stuff with Python

Practice Questions


文章目录

  • Automate The Boring Stuff with Python
    • Chap1 Python Basics


Chap1 Python Basics

  1. Which of the following are operators, and which are values?
*
'hello'
-88.8
-
/
+
5

Operater: *, -, /, +

Value: ‘hello’, -88.8, 5


  1. Which of the following is a variable, and which is a string?
spam
'spam'

Variable: spam

String: ‘spam’


  1. Name three data types.

String (str), integer (int), floating-point (float)


  1. What is an expression made up of? What do all expressions do?

An expression is made up of values and operations, and they can evaluate down to a single value. A single value without no operators is also considered an expression, though it evaluates only to itself.


  1. This chapter introduced assignment statements, like spam = 10. What is the difference between an expression and a statement?

An expression is a combination of values, variables, and operators that evaluates to a single value (e.g., 2 + 3 or spam + 5).

A statement is a complete line of code that performs an action, such as assigning a value (spam = 10) or controlling the flow of execution (e.g., if, for).

Expressions can be part of statements, but statements do not return a value.


  1. What does the variable bacon contain after the following code runs?
bacon = 20
bacon + 1

>>> 21


  1. What should the following two expressions evaluate to?
'spam' + 'spamspam'
'spam' * 3

>>> ‘spam’ + ‘spamspam’

>>> ‘spamspamspam’

>>> ‘spam’ * 3

>>> ‘spamspamspam’


  1. Why is eggs a valid variable name while 100 is invalid?

A valid variable name should ebey the following four rules:

  • It can’t have spaces
  • It can use only letters, numbers, underscore (_) character
  • It can’t begin with a number
  • It can’t be a Python keyword, such as if, for, return, or other keywords

  1. What three functions can be used to get the integer, floating-point number, or string version of a value?
    int() float() str()

  1. Why does this expression cause an error? How can you fix it?
'I eat ' + 99 + ' burritos.'

99 is an integer

'I eat ' + str(99) + ' burritos.'
http://www.dtcms.com/a/438565.html

相关文章:

  • Java 之继承与多态
  • 建设局电话965559seo综合查询平台官网
  • 做网站分辨率多少wordpress调查问卷插件
  • 东莞网站关键词优化排名wordpress init
  • 淘客APP的联盟规则适配层设计:如何通过策略模式快速响应淘宝/京东/拼多多政策变动?
  • Java-140 深入浅出 MySQL Spring事务失效的常见场景与解决方案详解(2)
  • AI心理类APP测评:产品设计、技术实现及对独立开发者的启示
  • AI编程开发系统013-基于Vue+SpringBoot的“知语”花卉销售网站(源码+演示视频+讲解+lw)
  • 广州有几个区分别叫什么南京做网站优化哪家好
  • 【Jitsi Meet】阿里云Docker安装Jitsi Meet后的调整
  • 企业网站颜色手机做网站软件
  • php入门
  • 深圳网站搭建哪里好奎文建设局网站
  • 用织梦建设网站杭州公司官方网站制作
  • 数仓各层级设计总结
  • 8.设计模式-两阶段终止(优雅停机)
  • 那里网站建设好广东建设信息网三类人
  • 网站建设百度小程序手机版网站怎么做
  • 上海机械网站建设工程网站开发
  • 网站功能说明怎么做为什么我的网站备案通过还是显示未备案
  • 校园门户网站系统建设白帽seo公司
  • nodejs中http模块搭建web服务器
  • 电子书管理与阅读平台BookHeaven
  • 网站建设有哪些分类做网站图片大小不合适怎么调
  • 【LeetCode - 每日1题】接雨水问题1
  • 太原cms建站先做网站还是先申请域名
  • 京东网站设计代码做淘宝客可以有高佣金的网站
  • wdcp创建网站网站建设如何增加二级页面
  • 阿联酋网站后缀星空无限传媒免费观看电视剧
  • 网站建设营销策划方案二次元动漫网站设计方案