楼主: UCLA34
跳转到指定楼层
上一主题 下一主题
收起左侧

打卡帖 告别拖延症~

🔗
 楼主| UCLA34 2021-9-8 16:05:14 | 只看该作者
全局:
MAX = sys.maxsize
float('inf')
float('-inf')
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-8 16:07:07 | 只看该作者
全局:
python: isdigit(), isalpha, isalnum()
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-8 16:10:03 | 只看该作者
全局:
print('Salary: ', person.get('salary'))
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-9 10:12:58 | 只看该作者
全局:
takeaway, input got in as string, so alway remember to convert them into integers

rowNumber = input()
sum = 0
for i in range(int(rowNumber)):
    row = input().split()
    sum += int(row[i])
    #print(row[i])

print(sum)

回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-9 22:34:12 | 只看该作者
全局:


when you do .extend,
the input should be a list

also, check sometimes if you mistake == for =
it will compile and it will run, but it will fail
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-10 04:20:45 | 只看该作者
全局:
print([['A'] * 10 ])
print([['A'] for _ in range(10)])

[['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']]
[['A'], ['A'], ['A'], ['A'], ['A'], ['A'], ['A'], ['A'], ['A'], ['A']]
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-10 04:35:57 | 只看该作者
全局:
all() function can be very handy     


def win(self, board, token):
      n = len(board)
      
      for j in range(n):
        if all(board[i][j] == token for i in range(n)): return True
        if all(board[j][i] == token for i in range(n)): return True
      
      if all(board[i][i] == token for i in range(n)):return True
      
      if all(board[n - 1 - i][i] == token for i in range(n)):return True
      
      return False
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-12 14:13:44 | 只看该作者
全局:
n = int(input())

result = 100.00
height = 100.00
for i in range(n - 1):
    result += height
    height /= 2

print(f'{result:.2f}')
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-12 14:14:04 | 只看该作者
全局:
UCLA34 发表于 2021-9-12 02:13
n = int(input())

result = 100.00

Round to second digit after decimal
回复

使用道具 举报

🔗
 楼主| UCLA34 2021-9-27 09:53:11 | 只看该作者
全局:
Second, a dictionary key must be of a type that is immutable. For example, you can use an integer, float, string, or Boolean as a dictionary key. However, neither a list nor another dictionary can serve as a dictionary key, because lists and dictionaries are mutable. Values, on the other hand, can be any type and can be used more than once.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表