Variables and Data Type Excercises
Variables and Data Type Excercises
my_text=""
print(my_text)
Q3
name=input("Please enter your name.")
#Type your answer here.
str="Hello!, ".format()
print(str)
glass_of_water=
men_stepped_on_the_moon=
print()
Q6Using type() function assign the type of the variable to answer_1, then print it.
men_stepped_on_the_moon=12
answer_1=
print(answer_1)
my_grade="10"
answer_5=
print(answer_5)
my_temp=97.70
answer_6=
print(answer_6)
Q9#GWP denotes the total economic activity created by the world population
collectively in a year.
gross_world_product=84.84
gwp_str=
answer_8="In 2018 gross product of the world (GWP) was " + gwp_str + " in trillion
US dollars."
print(answer_8)
print(answer_1)
print(gift_list)
Q12Lists can hold many type of data inside them. You can even add another list to a
list as its element. This is called nested data in Python.
#On line below, this time add the sub-list: ["socks", "tshirt", "pajamas"] to the
end of the gift_list.
print(gift_list)
print(gift_list)
Q14With .index() method you can learn the index number of an item inside your list.
Assign the index no of 8679 to the variable answer_1.
answer_1=
print(answer_1)
Q15Using .append() method, add a new list to the end of the list which contains
strings: "Navigator" and "Suburban".
print(lst)
print(lst)
print(answer_1)
print(answer_1)
print(dict["born"])
Q20Dictionaries can have nested data too. Also, you can add a new key to a
dictionary as they are mutable (changeable). Try to add the key "work" to dict with
values shown below.
"work": ["Apology", "Phaedo", "Republic", "Symposium"]
print(dict)
dict = {"son's name": "Lucas", "son's eye color": "green", "son's height": 32,
"son's weight": 25}
print (ans_1)
print(str)
Q23Make the string so that everything is properly and first letter is capital with
one function.
print(str)
ans_1=
print(ans_1)
Q25Does it end with a fullstop (.) ?
ans_1=
print(ans_1)
ans_1=
print(ans_1)
ans_1=
print(ans_1)
str="1.975.000"
ans_1=
print(ans_1)
ans_1=
Q30This time ask the user a numerical question, such as, "Please enter your age."
See what type of data input() returns.
#Type your code here.
ans_1=
print(type(ans_1))
Q31Create a converter that will ask for amount of days and convert it to years,
then print it.
Using int() function convert the user's answer to integer. And then make your
calculation.
You can ask something like: "How many days would you like to convert to a year?"
message=
result=
print(result)
rng=
print(rng)
Type something so that Python gives a TypeError.
Q33Create a range from 100 to 160 with steps of 10. Then print it as a list.
Q34Can you you create a list from 1300 to 700 with descending steps of 100? Is your
stop value included in the list?
Q42Three MBA students purchased a different asset yesterday at the below listed
price. Each sold their asset today at the listed selling price.
Calculate the percent return for each student rounded to two decimal points.
Student buy sell
Jen $25.50 $40.20
Jacobi $103.30 $125.00
Mark $86.02 $91.41
Calculate the maximum of the LIST of returns.
You go to the store with $15 to buy pears, each pear is a $1.35, how many pears can
you buy? (You cannot buy partial pears so round your results).