Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022/03/05 Start the Python Program! #2

Open
handyZYG opened this issue Apr 19, 2022 · 0 comments
Open

2022/03/05 Start the Python Program! #2

handyZYG opened this issue Apr 19, 2022 · 0 comments

Comments

@handyZYG
Copy link
Owner

handyZYG commented Apr 19, 2022

image

The core of extensible programming is defining functions. Python allows mandatory and optional arguments, keyword arguments, and even arbitrary argument lists.

image
First of all, install the PyCharm to configure my python environment.

Try to use the PyCharm to create my first Python program!
image
(That is not only the Hello world program, but also the big step to study the Python!XD

Let`s code a REAL hello world! lolllll
image
(U can use the SHIFT + F9 to encode the codes by keyboard)

Then try a input:
image

And some math?
image

Let`s try some circle, btw we can use the:
print(' ', end = ' '
let it print for one line.
image

If u want to input a num not a string as normal?
r = int(input())
Do a math of a circle?
image

This is the point!
How to print a num in Binary/Octal/Hex!
a = int(input()) str1 = str(bin(a)) print(str1[2:], end=' ') str2 = str(oct(a)) print(str2[2:], end=' ') str3 = str(hex(a)) print(str3[2:])
Here it is!
image

Let`s do some big!
Try to find the MAX/MIN/AVERAGE num from a num list!
n = int(input()) list1 = list(map(eval,input().split())) Max = str(max(list1)) print('max=%s' % Max) Min = str(min(list1)) print('min=%s' % Min) sum = 0 for i in range(n): sum = sum + list1[i] Avg = sum/n print('average=%.2f' % Avg)
image

ALL IS GOOD!
And this is my first lesson to study Python, I got really much, see u next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant