1-python Getting Started 1

Source: Internet
Author: User
Tags control characters

Memory management: After the Python variable is re-assigned, the corresponding memory address will change

Reference count

Del is unbound

Memory address multiplexing

>>> x=1>>> id(x)9310240>>> x=2>>> id(x)9310272>>> y=1>>> id(y)9310240

String Formatting control characters

print(‘用户名是: %s 密码是: %s‘ %)
Print with while loop 1 2 3 4 5 6 8 9 10
x = 1print(‘Now, Print the numbers: ‘, end=‘ ‘)while x < 11:    print(x, end=‘ ‘)    if x == 6:        x += 2        print("  ", end=‘‘)    else:        x += 1
Method Two
print(‘\n‘)x = 0while x < 10:    x += 1    if x == 7:        continue    print(x, end=‘ ‘)
Ask for 1-100 and
print(‘\n‘)y = 1sum = 0while y < 101:    sum += y    y += 1print(‘1-100的所有数的和是:‘, sum)print(‘\n‘)
Ask for all the even numbers within 1-100
print(‘100以内所有的偶数: ‘, end=‘‘)for i in range(1, 101):    if i % 2 == 0:        print(i, end=‘ ‘)
Ask for an odd number within 100
print(‘\n‘)print(‘100以内所有的奇数: ‘, end=‘ ‘)for ii in range(1, 101):    if ii % 2 != 0:        print(ii, end=‘ ‘)print(‘\n‘)
Beg 1-2+3-4+5 ... 99 of all numbers of the and
sum = 0for i in range(1, 100):    if i % 2 == 0:        sum -= i        print(‘-‘, i, end=‘‘)    else:        sum += i        print(‘+‘, i, end=‘‘)print(‘=‘, sum)
User Login (three chance retry)
username = (‘cx2c‘)password = (‘cx2c‘)for i in range(1,4):    user=input(‘Please Input Your Name: ‘)    pasw=input(‘Please Input Your Password: ‘)    if username == user and password==pasw:        print(‘Login in successful‘)        break    else:        print(‘The %sth time False,Try Again‘ %i)
Print results
Now, Print the numbers:  1 2 3 4 5 6   8 9 10 1 2 3 4 5 6 8 9 10 1-100的所有数的和是: 5050100以内所有的偶数: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 100以内所有的奇数:  1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 + 1- 2+ 3- 4+ 5- 6+ 7- 8+ 9- 10+ 11- 12+ 13- 14+ 15- 16+ 17- 18+ 19- 20+ 21- 22+ 23- 24+ 25- 26+ 27- 28+ 29- 30+ 31- 32+ 33- 34+ 35- 36+ 37- 38+ 39- 40+ 41- 42+ 43- 44+ 45- 46+ 47- 48+ 49- 50+ 51- 52+ 53- 54+ 55- 56+ 57- 58+ 59- 60+ 61- 62+ 63- 64+ 65- 66+ 67- 68+ 69- 70+ 71- 72+ 73- 74+ 75- 76+ 77- 78+ 79- 80+ 81- 82+ 83- 84+ 85- 86+ 87- 88+ 89- 90+ 91- 92+ 93- 94+ 95- 96+ 97- 98+ 99= 50Please Input Your Name: cx2cPlease Input Your Password: ccFalsePlease Input Your Name: cx2cPlease Input Your Password: cx2cLogin in successful

Getting started with 1-python 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.