0% found this document useful (0 votes)
20 views3 pages

HandsOnExs Variables and DataType

Uploaded by

hanyeelovesgod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

HandsOnExs Variables and DataType

Uploaded by

hanyeelovesgod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

035.

001 Digital Computer Concept and Practice (Spring, 2024)


Hands-on Exercises on Variables and Data Types

# Note : You can use Python's built-in functions, but importing external packages is NOT allowed
since they are beyond the scope of the current exercises

1. A quadratic polynomial equation is given as below:


2x2 + 7x - 5 = 0
Solve for the variable x based on the quadratic formula.
> Note: The quadratic formula of the general quadratic equation ax2 + bx + c = 0 is defined as :

−𝑏𝑏 ± √𝑏𝑏 2 − 4𝑎𝑎𝑎𝑎


𝑥𝑥 =
2𝑎𝑎

2. Answer below questions by referring to a string variable msg2:


msg2 = ‘What is your favorite genre of music?’
(a) What is the length of the string variable?
(b) What are msg2[13]? msg2[-11:-5]? msg2[6:]?
(c) How can you print ‘favorite genre’ via slicing?
(d) How can you revise the variable as ‘What is your favorite movie?’

3. Find a quote from a famous person you admire. Store the famous person’s name in a variable called
famous_person. Then compose your message and store it in a new variable called msg3. Print your
message and the name of its author. Your output should look something like below, including the
quotation marks. i.e., :
Abraham Lincoln once said, “I walk slowly, but I never walk backward.”

Page | 1
4. Store your favorite number greater than 10 in a variable. By using that variable, answer below
questions.
(a) In a variable msg41, create a message that reveals your favorite number. Print that message.
(b) Evaluate whether your favorite number is the multiple of 6. In a variable msg42, make a message
to report the result and print it.
(c) Calculate the quotient of your favorite number and 4. In a variable msg43, make a message to
report the result and print it.

5. Let’s imagine that you have organized one-day spring trip with your four friends (Ben, Paul, Sarah,
and Jane). Store the name of the trip members in a list called name_members. By employing the list
variable, solve below questions.
(a) Print a message to individual friends. The text of each message should be the same as “Let’s meet
in the Seoul station at 9 o’clock tomorrow.” But each message should be personalized with the
person’s name.
(b) Update the list name_members by referring to Kakao-talk messages sent by a few of your friends
as below:
> From Paul : Sorry, I won’t be able to join in the trip.
> From Sarah : Hey! I will come over with my friends Cohen and Laura.
(c) Print the final number of the trip members.

Page | 2
6. The following Table 1 shows the annual mean precipitation for the years of 1991-2020 (i.e.,
climatological normal) at 8 meteorological stations in Korea.

Station name Precipitation [mm]


Seoul 1418
Incheon 1207
Daejeon 1351
Ulsan 1293
Gwangju 1381
Busan 1577
Jeju 1502
Daegu 1081
(reference : https://data.kma.go.kr/normals/table.do)
(a) Make a dictionary called CN_Prep_mm_KOR, to store the information in Table 1 with the string
keys for station name and integer values for the corresponding precipitation.
(b) Write a program to calculate the average and the standard deviation of the annual mean
precipitation over all stations.
(c) Report the results from (b) by printing string variables named msg61 and msg62 for the average
and the standard deviation, respectively.
(d) To the dictionary created in (a), add the info on the annual mean precipitation of 1449 mm at
Yeosu station.
(e) Report the keys in the updated dictionary CN_Prep_mm_KOR.

Page | 3

You might also like