MIS3011S Introduction to Programming

University College Dublin
MIS3011S Introduction to Programming
Practical 8
Miguel Nicolau

  1. What is the output of the following Python code?
    full
    stock = 976
    current
    stock = full
    current
    stock-= 34
    print(full
    stock)
    stock
  2. What is the output of the following Python code?
    featured
    brand = “Sony”
    brands = [featured
    brand, “Canon”, “Nikon”, “Fujifilm”]
    featured
    brand = “Fujifilm”
    print(brands)
  3. What is the output of the following Python code?
    root
    vine
    vegetables = [“turnip”, “carrot”, “potato”]
    fruits = [“kiwi”, “grape”, “tomato”]
    produce = root
    vegetables + vine
    del root
    vegetables[1]
    print(produce)
    fruits
  4. What is the output of the following Python code?
    travel
    plans = [“Mexico”, “USA”, “Panama”, “Cuba”]
    current
    trip = travel
    while len(current
    plans
    trip) > 0:
    print(“Visiting”, current
    trip.pop())
    print(“Countries left to visit:”, travel
    1
    plans)
  5. What is the output of the following Python code?
    digits = [*range(10)]
    lucky
    number = digits[5]
    digits = digits[1:-1]
    print(lucky
    number)
  6. What is the output of the following Python code?
    operations = [“//”, “**”, “+”, “-”, “*”, “/”]
    basic
    operations = operations[2:]
    operations.pop()
    operations.pop()
    print(basic
    operations)
  7. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = codes
    codes.append(1)
    print(new
    codes)
  8. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = list(codes)
    codes.append(1)
    print(new
    codes)
  9. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = codes
    codes = codes[:2]
    print(new
    codes)
  10. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = codes
    del codes[2]
    print(new
    codes[2])
    2
  11. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = codes
    del codes[2]
    try:
    print(new
    codes[3])
    except:
    print(“Code does not exist.”)
  12. What is the output of the following Python code?
    codes = [351, 32, 353, 33]
    new
    codes = codes[:]
    del codes[2]
    try:
    print(new
    codes[3])
    except:
    print(“Code does not exist.”)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值