1
1
from sys import argv
2
+ #from os.path import exists
2
3
3
- print ("How old are you?" , end24 = ' ' )
4
+ print ('What is your name?' , end = ' ' )
5
+ name = input ()
6
+ print ("How old are you?" , end = ' ' )
4
7
age = input ()
5
8
print ("How tall are you?" , end = ' ' )
6
9
height = input ()
7
10
print ("How much do you weigh?" , end = ' ' )
8
11
weight = input ()
9
12
10
- print (f"So, you're { age } old, { height } tall and { weight } heavy." )
13
+ print (f"So, your name is { name } , you're { age } years old, { height } cm tall and { weight } kg heavy.\n " )
11
14
12
- print ("After this you need to open ### Open file and print" )
15
+ print ("After this you need to open file and print\n " )
13
16
14
- filename = argv
17
+ # Opening test.txt
18
+
19
+ script , filename = argv
15
20
16
21
txt = open (filename )
17
- print ("Here's your file {filename}:" )
22
+ print (txt .read ())
23
+
24
+ print (f"Here's your file { filename } :" )
18
25
print (txt .read ())
19
26
20
27
print ("Type the filename again:" )
21
28
file_again = input ("> " )
22
29
23
30
txt_again = open (file_again )
31
+ indata = txt_again .read ()
24
32
25
- print (txt_again ())
26
- ###
33
+ print (txt_again .read ())
34
+ print (f"\n The input file is { len (indata )} bytes long" )
35
+ txt .close ()
36
+ txt_again .close ()
37
+ #
27
38
28
39
29
- print ('Let \' s practice everything.' )
30
- print ('You\' d need to know \' bout escapes with \\ that do \n newlines and \t tabs.' )
40
+ print ('\n Let \' s practice everything.' )
41
+ print ('You\' d need to know \' bout escapes with \\ that do \n newlines and \t tabs.\n ' )
31
42
32
43
poem = """
33
44
\t The lovely world
40
51
41
52
print ("--------------" )
42
53
print (poem )
43
- print ("--------------" )
54
+ print ("--------------\n " )
44
55
45
56
46
57
five = 4 - 2 + 4 - 1
47
- print (f"This should be five: { five } " )
58
+ print (f"This should be five: { five } \n " )
48
59
49
60
def secret_formula (started ):
50
61
jelly_beans = started * 500
@@ -54,38 +65,38 @@ def secret_formula(started):
54
65
55
66
56
67
start_point = 10000
57
- beans , jars = secret_formula (start_point )
68
+ beans , jars , crates = secret_formula (start_point )
58
69
59
70
# remember that this is another way to format a string
60
- print ("With a starting point of: {}" .format (start_point ))
71
+ print ("\n With a starting point of: {}" .format (start_point ))
61
72
# it's just like with an f"" string
62
73
print (f"We'd have { beans } beans, { jars } jars, and { crates } crates." )
63
74
64
75
start_point = start_point / 10
65
76
66
77
print ("We can also do that this way:" )
67
- formula = secret_formula (startpoint )
78
+ formula = secret_formula (start_point )
68
79
# this is an easy way to apply a list to a format string
69
80
print ("We'd have {} beans, {} jars, and {} crates." .format (* formula ))
70
81
71
82
72
83
73
84
people = 20
74
- cates = 30
85
+ cats = 30
75
86
dogs = 15
76
87
77
88
78
89
if people < cats :
79
- print ("Too many cats! The world is doomed!" )
90
+ print ("\n \n Too many cats! The world is doomed!" )
80
91
81
92
if people > cats :
82
93
print ("Not many cats! The world is saved!" )
83
94
84
95
if people < dogs :
85
- print ("The world is drooled on!" )
96
+ print ("Too many dogs! The world is drooled on!" )
86
97
87
98
if people > dogs :
88
- print ("The world is dry!" )
99
+ print ("Too many people! The world is dry!" )
89
100
90
101
91
102
dogs += 5
@@ -96,6 +107,5 @@ def secret_formula(started):
96
107
if people <= dogs :
97
108
print ("People are less than or equal to dogs." )
98
109
99
-
100
110
if people == dogs :
101
111
print ("People are dogs." )
0 commit comments