40923121

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • Develop
  • 作業
    • 40923121 hw1
      • PCH7 Expansion Card Audio Video and Storage
      • Expansion Slots
      • PCI PCI X Slots
      • Summary
      • PCI Express  PCIe  Expansion Slots
      • AMR and CNR Slots
      • Overclocking
      • Choosing a Processor
      • CPU Cache
      • Video Output
      • Storage Devices  Optical Drives
      • Storage Devices  External Devices
      • Storage Devices  Legacy Devices
      • 擴展插槽
      • PCI   PCI-X插槽
      • 概要
      • PCI Express PCIe 擴展插槽
      • AMR和CNR插槽
      • 超頻
      • 選擇處理器
      • CPU緩存
      • 視頻輸出
      • 存儲設備 光盤驅動器
      • 存儲設備 外部設備
      • 存儲設備 舊版設備
      • Overview
      • Heat Sources
      • Heat Effects
      • Heat Reduction
      • Active Air Cooling
      • Passive Air Cooling
      • Liquid Cooling
      • CPU Cooling
      • Case Fans
      • Liquid Cooling Installation
      • 總覽
      • 熱源
      • 熱效應
      • 減少熱量
      • 主動風冷
      • 被動風冷
      • 液體冷卻
      • CPU散熱
      • 機箱風扇
      • 液體冷卻 安裝
    • hw2
    • hw3
      • Discussion-1
      • Sets
      • Features of sets
      • In Python
      • 討論區-1
      • 集的特徵
      • 在Python中
      • Discussion-2
      • More string things
      • Splitting strings
      • Joining strings
      • 討論區-2
      • 更弦的東西
      • 分割字符串
      • 連接字符串
      • Discussion-3
集的特徵 << Previous Next >> Discussion-2

在Python中

在Python中,使用set()關鍵字set並使用set 。例如:

  names = set()
  names.add("Michele")
  names.add("Robin")
  names.add("Michele")
  print(names)

輸出將是;

  set(['Michele', 'Robin'])

您可以設置一個集合,幾乎可以對列表執行任何操作(要求“第三個元素”之類的東西除外)。請參閱有關集合的Python文檔,以獲取可以對集合進行操作的完整列表。

您可以很容易地將列表轉換為集合,然後將集合轉換為列表:

  names = ["Michele", "Robin", "Sara", "Michele"]
  names = set(names)
  names = list(names)
  print(names)


15  Reverse Word Order 
Exercise 15  and Solution

Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string:

  My name is Michele

Then I would see the string:

  Michele is name My

shown back to me.


集的特徵 << Previous Next >> Discussion-2

Copyright © All rights reserved | This template is made with by Colorlib