-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
snow feng
committed
Apr 19, 2024
1 parent
093e6a6
commit 59290b9
Showing
10 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/python | ||
# Filename : ch02/hello1.py | ||
|
||
import world1 | ||
from world1 import z | ||
from world1 import x as x2 | ||
|
||
x = 100 | ||
y = 20 | ||
|
||
print (world1.x) | ||
print (y) | ||
print (z) | ||
print (x2) | ||
print (x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coding=utf-8 | ||
# Filename : ch02/world1.py | ||
|
||
x = '你好' | ||
y = True | ||
z = 20.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_2_1_2_snow.py | ||
|
||
i = 0 | ||
|
||
while i * i < 100099: | ||
i += 1 | ||
if i == 55: | ||
break | ||
print(str(i) + '*' + str(i) + ' =', i * i) | ||
else: | ||
print('While Over') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_2_2_1_snow.py | ||
|
||
print("------字符串--------") | ||
for item in '我是你爸爸': | ||
print(item) | ||
|
||
numbers = [54188 ] | ||
print("---------整数列表---------") | ||
for item in numbers: | ||
print(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_2_2_2.py | ||
|
||
for item in range(10): | ||
print(item) | ||
else: | ||
print('For Over') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_2_2_2_1.py | ||
|
||
for item in range(10): | ||
print(item) | ||
if item ==30: | ||
break | ||
else: | ||
print('For Over') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_3_1.py | ||
|
||
for item in range(10): | ||
if item == 3: | ||
break | ||
print(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_3_2.py | ||
|
||
for item in range(10): | ||
if item == 2 or item == 4 or item == 6 or item == 8: | ||
continue | ||
print(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# coding=utf-8 | ||
# Filename: ch5_3_2.py | ||
|
||
i = 100; r = 0; s = 0; t = 0 | ||
|
||
while i < 1000: | ||
r = i // 100 | ||
s = (i - r * 100) // 10 | ||
t = i - r * 100 - s * 10 | ||
if i == (r ** 3 + s ** 3 + t ** 3): | ||
print("i = " + str(i)) | ||
|
||
i += 1 |