Skip to content

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

@handyZYG

Description

@handyZYG

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions