Lab 1
Byungjoo Lee
Yonsei University
AIC2100 AI Programming with Python
Lab 1 AIC2100
2
You must follow the specification thorougly!
• Any typos (including whitespace and linebreak) will result in a point deduction.
• If you’re asked to write the comment or docstring, you must add them.
• If some Python libraries are prohibited, importing them will result in 0 points.
• Depending on the lab content, additional rules can be added.
• Please read the specification document carefully and submit your code.
• We won't accept appeals for point deductions based on misinterpreting the lab specification
documentation.
• If any specification is unclear, please post your question on the Q&A board.
Lab 1 AIC2100
3
Please refer to the guidelines noted in previous labs. They remain applicable for this and
subsequent labs.
Any updates in guidelines will be announced again.
Coding guideline
Lab 1 AIC2100
4
Notation
• To clearly instruct the lab specifications, (1) we use “˽” to depict a whitespace (blank)
character and (2) “¤” for a “
” (newline) character.
• Underlined text refers to the user input (will be demonstrated again in a further lab).
• New notations will be demonstrated additionally on there first mention.
Lab 1 AIC2100
5
One important note about automated archiving
• In lab0, the automated archive code used the incorrect folder name format “{student_id}”.
• It should have been “lab{X}_{student_id}”. (Sorry)
• Don’t worry, we did not deduct your point with this since it is our mistake.
• In the slides explaning the automated archive code (ap_lab0.pdf p.15-16), we specified the
wrong format, while in the slide explaning manual archiving (p. 17), we specified the correct
format.
• We revised the code and update it to LearnUs, even though it is outdated.
• TL;DR
• If you want to use automated archiving, just use our provided code. You don’t need to
revise it on your own.
• If you manually archived in Lab 0, “lab{X}_{student_id}” foldername is correct.
Lab 1 AIC2100
6
Problem 1
Write a program that allows the user to enter any integer base and integer exponent, and displays
the value of the base raised to that exponent. Your program should work as shown below.
Note 1. You do not have to consider faulty input. More specifically, we will test your program for
integer inputs only.
Note 2. The integer base and exponent will be non-negative.
This program needs to ask two times for input from the user. The input prompt with the second
input() command depends on the input from the first input() command. This is highlighted in the
following example:
What˽base?˽10¤
What˽power˽of˽10?˽4¤
10˽to˽the˽power˽of˽4˽is˽10000¤
Lab 1 AIC2100
7
Problem 1
Here are some examples.
What˽base?˽0¤
What˽power˽of˽0?˽5¤
0˽to˽the˽power˽of˽5˽is˽0¤
What˽base?˽2¤
What˽power˽of˽2?˽10¤
2˽to˽the˽power˽of˽10˽is˽1024¤
What˽base?˽5¤
What˽power˽of˽5?˽0¤
5˽to˽the˽power˽of˽0˽is˽1¤
What˽base?˽-25¤
What˽power˽of˽-25?˽3.7¤
You don’t need to consider non-integer inputs.
Lab 1 AIC2100
8
Problem 1
FAQ
Q. What is 0
0?
A. Mathematically, it converges to 1 and Python will output 1 too.
Lab 1 AIC2100
9
Problem 2
Write a program that allows the user to enter a base integer and a four-digit number, and displays
its value in base 10. Each digit should be entered one per line, starting with the leftmost digit, as
shown below. This program also needs to ask several times for input from the user. The output
depends on the input from input() command. This is highlighted in the following example:
Enter˽the˽base˽integer:˽2¤
Enter˽leftmost˽digit:˽1¤
Enter˽the˽next˽digit:˽0¤
Enter˽the˽next˽digit:˽0¤
Enter˽the˽last˽digit:˽1¤
Your˽input˽is˽1001˽in˽base˽2¤
The˽value˽is˽9˽in˽base˽10¤
Example 1
Enter˽the˽base˽integer:˽5¤
Enter˽leftmost˽digit:˽0¤
Enter˽the˽next˽digit:˽3¤
Enter˽the˽next˽digit:˽4¤
Enter˽the˽last˽digit:˽2¤
Your˽input˽is˽0342˽in˽base˽5¤
The˽value˽is˽97˽in˽base˽10¤
Example 2
Lab 1 AIC2100
10
Problem 2
Note 1. You can assume that the base integer is integer from 2 to 10 and four-digit numbers are
non-negative integers.
Note 2. You do not have to consider faulty inputs. There are two cases.
- Invalid base integer input (non-integer or out-of-range)
- Invalid four-digit number (non-integer or exceeding base integer)
Note 3. You don’t need to omit starting zeros when printing your input digit numbers (e.g., if your
input is 0011, then print 0011, not 11). See example 2 in the previous slide.
Lab 1 AIC2100
11
Problem 3
Write a program in which the user can enter any number of positive and negative integer values,
that displays the number of positive values entered and their summation, as well as the negative
values. Your program should work in following conditions.
1. Exclude all numbers that aboslute value is greater than 100 (i.e.,
- HGC环电强化国际业务领导架构 谭君骥及Ravindran Mahalingam分别担任专精职务
- 海伯森六维力传感器:助力人形机器人产业发展的创新力量
- 达闼董事长黄晓庆:以技术破局致胜从未止步
- 从辅助到核心,企业如何基于AI Agent升级品牌数字营销
- 国产2.5亿超高分辨率图像传感器发布,主要面向机器视觉领域
- 西部数据推出多款超高速、大容量存储解决方案
- 中关村e谷承办“科创耀未来 奋进谱新篇”企业家创新论坛圆满落幕
- 航科卫星“汕头数字一号”卫星发射成功!
- Gartner 最新魔力象限出炉!ManageEngine卓豪成功入围
- 科技重塑物流,英特尔&集和诚加速智慧物流发展!
- 数智赋能 向“新而行” 坦克与装甲车辆学术与发展论坛召开
- 赛诺威盛:大孔径专科化CT领航者
- 网易硬刚腾讯 两大游戏玩家之间的口水仗不断
- 全球“最独特”的一台华为 nova 6 5G 版手机是什么样子的?
- 拼多多抖音淘宝京东,谁是真低价?