selfteaching / selfteaching/selfteaching-python-camp

Day05 int类型怎么转换成2进制?

Open
#4,348 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

#数组操作,进制转换
list=[0,1,2,3,4,5,6,7,8,9]
list.reverse() #将数组按顺序翻转
print("将数组翻转")
print(list)

list1= [str(x) for x in list] # list里的int数字转换为字符串
t1="".join(list1) #将列表中各个字符拼接成字符串
print("将列表中各个字符拼接成字符串")
print(t1)

t2=t1[2:8] #分切取出38的字符
t3=[int(x) for x in t2]
t3.reverse() #字串翻转并转换为int类型
print("分切取出3
8的字符并翻转")
print(t3)
print("转换为2进制")
print(bin(t3))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the final print statement, bin(t3), and consult Python's documentation for bin() and its accepted argument type. Confirm the intended conversion for the values in t3, then verify that the example runs and produces the expected binary representation without passing an unsupported collection.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.