2-1/2-2:
message = "helloworld"
print(message)
message = "hello python"
print(message)
2-3/2-4:
user_name = "Galileo Galilei"
print('"Hello ' + user_name + ", would you like to learn\
some Python today?" + '"')
print(user_name.lower())
print(user_name.upper())
print(user_name.title())
2-5/2-6:
famous_person = "Galileo Galilei"
wisdom = "Life is like the anvil, the more to be beat, the more able to spark."
print(famous_person + 'once said,"' + wisdom + '"')
message = famous_person + 'once said,"' + wisdom + '"'
print(message)
2-7:
uname = " \t\n Hu Dalao \t"
print(uname)
print(uname.lstrip())
print(uname.rstrip())
print(uname.strip())
2-8:
import math
print(2+6)
print(10-2)
print(2*4)
print(math.floor(16/2))
2-9:
favorite_num = 12
print("my favorite number is: " + str(favorite_num))
2-10:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 10 21:49:18 2018
@author: huangdr
this program is homework
"""
message = "helloworld"
print(message)
message = "hello python"
print(message)
2-11:
>>>import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!