Learning Circle : python #1 - ex3, ex4
This commit is contained in:
parent
8ccbd1f8e2
commit
526f0688a1
6 changed files with 64 additions and 5 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,6 +1,3 @@
|
|||
/youngjin.han/dot-cdist/type/__my_computer/manifest~
|
||||
/youngjin.han/cdist.org~
|
||||
/youngjin.han/dot-cdist/type/__colourful_file/file/colourful~
|
||||
/youngjin.han/dot-cdist/type/__colourful_file/manifest~
|
||||
/youngjin.han/dot-cdist/type/__all_in_one/manifest~
|
||||
manifest~
|
||||
*.py~
|
||||
*.org~
|
||||
|
|
9
youngjin.han/python-the-hard-way/ex3-1.py
Normal file
9
youngjin.han/python-the-hard-way/ex3-1.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
f_pi = 3.14159265358979
|
||||
|
||||
print("org =", f_pi)
|
||||
print("trans format 1 = %.2f" % f_pi)
|
||||
print("trans format 2 =", round(f_pi, 2))
|
||||
print("trans format 3 = %.2f" % round(f_pi, 2))
|
||||
print("trans format 4 = {:.2f}".format(f_pi))
|
||||
print("trans format 5 = {:.2f}".format(round(f_pi, 2)))
|
||||
print("trans format 6 = {:.15f}".format(round(f_pi, 2)))
|
4
youngjin.han/python-the-hard-way/ex3-2.py
Normal file
4
youngjin.han/python-the-hard-way/ex3-2.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
print((2**8) - 1)
|
||||
print((2**16) - 1)
|
||||
print((2**32) - 1)
|
||||
print((2**64) - 1)
|
21
youngjin.han/python-the-hard-way/ex3.py
Normal file
21
youngjin.han/python-the-hard-way/ex3.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
print("Hens", 25 + 30 / 6) # 25 + (30 / 6) = 25 + 5 = 30
|
||||
|
||||
print("Roosters", 100 - 25 * 3 % 4) # 100 - (25 * 3 % 4) = 100 - (75 % 4) = 100 - 3 = 97
|
||||
print("Now I will count the eggs:") # print syntex
|
||||
|
||||
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) # 3 + 2 + 1 - 5 + 0 - 0.25 + 6 = 6.75
|
||||
|
||||
print("Is it true that 3 + 2 < 5 - 7?") # print syntex
|
||||
|
||||
print(3 + 2 < 5 - 7) # 5 < -2 => false
|
||||
|
||||
print("What is 3 + 2?", 3 + 2) # 5
|
||||
print("What is 5 - 7?", 5 - 7) # -2
|
||||
|
||||
print("Oh, that's why it's False.") # print syntex
|
||||
|
||||
print("How about some more.") # print syntex
|
||||
|
||||
print("Is it greater?", 5 > -2) # true
|
||||
print("Is it greater or equal?", 5 >= -2) # true
|
||||
print("Is it less or equal?", 5 <= -2) # false
|
17
youngjin.han/python-the-hard-way/ex4.py
Normal file
17
youngjin.han/python-the-hard-way/ex4.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
cars = 100 # amount of car
|
||||
space_in_a_car = 4.0 # amount of seats in the car
|
||||
drivers = 30 # amount of driver
|
||||
passengers = 90 # amount of passenger
|
||||
cars_not_driven = cars - drivers # amount of person which could not drive = 70
|
||||
cars_driven = drivers # amount of person which could drive = 30
|
||||
carpool_capacity = cars_driven * space_in_a_car # amount of seat for carpool = 120
|
||||
average_passengers_per_car = passengers / cars_driven # 3
|
||||
|
||||
|
||||
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.")
|
11
youngjin.han/python.org
Normal file
11
youngjin.han/python.org
Normal file
|
@ -0,0 +1,11 @@
|
|||
* 2020-05-18
|
||||
** note
|
||||
- ex1.py
|
||||
- # is commnet.
|
||||
- ex2.py
|
||||
- I do't find mistakes.
|
||||
- ex3.py
|
||||
- none
|
||||
- ex4.py
|
||||
- car_pool_capacity is not defined.
|
||||
|
Loading…
Reference in a new issue