 A set of practice questions that a beginner of Python should be able to answer quite quickly if he/she has grasped the subject. Practice can help and one should not just learn it by heart. * x = 3 y = x + 3 y = int(str(y) + "2") print(y) Output - 62 * x = 3 num = 17 print(num % x) Output - 2 * list = [1, 1, 2, 3, 5, 8, 16] print(list[list[4]]) Output - 8 A bit confusing for beginners but it is easy to grasp and do try substituting various numbers and practice it. * letters = ['x', 'y', 'z'] letters.insert(1, 'w') print(letters[2]) Output - y * def print_nums(x): for i in range(x): print(i) return print_nums(10) Output - 0 * def func(x): res = 0 for i in range(x): res += i return res print(func(4)) Output - 6 * try: print(1) assert 2 + 2 == 5 except AssertionError: print(3) except: print(4) Output - 3 * nums = (55, 44, 33, 22, 11) print(max(min(nums[:2]), abs(-42))) Output - 44 Questions are from the Python learning app - Solo learn.
author | filler | ||||||
---|---|---|---|---|---|---|---|
permlink | python-practice-tests | ||||||
category | coding | ||||||
json_metadata | {"tags":["coding","python","neoxian","computer","education"],"image":["https://cdn.steemitimages.com/DQmfK3NSLkgix84XPWi78DAAZrEooeNpkUsDg6Xsv55zdqC/python.JPG"],"app":"neoxiancity/0.1","format":"markdown","canonical_url":"https://www.neoxian.city/@filler/python-practice-tests"} | ||||||
created | 2019-10-28 17:07:33 | ||||||
last_update | 2019-10-28 17:07:33 | ||||||
depth | 0 | ||||||
children | 4 | ||||||
last_payout | 2019-11-04 17:07:33 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.858 HBD | ||||||
curator_payout_value | 0.883 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 1,113 | ||||||
author_reputation | 4,924,532,976,740 | ||||||
root_title | "Python practice tests" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 91,986,943 | ||||||
net_rshares | 7,271,806,107,105 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
wackou | 0 | 97,827,361,468 | 1.44% | ||
tombstone | 0 | 239,336,585,150 | 0.86% | ||
drifter1 | 0 | 744,520,431 | 4.8% | ||
chris4210 | 0 | 15,197,879,975 | 2.4% | ||
steemship | 0 | 1,181,367,484,366 | 100% | ||
beerbloke | 0 | 892,266,544 | 12.5% | ||
eric-boucher | 0 | 9,412,694,960 | 2.4% | ||
anwenbaumeister | 0 | 226,120,586 | 4.8% | ||
mammasitta | 0 | 1,136,069,350 | 0.24% | ||
matt-a | 0 | 89,201,729,379 | 2% | ||
redpalestino | 0 | 191,100,695,671 | 2.4% | ||
diana.catherine | 0 | 665,423,621 | 4.8% | ||
blueorgy | 0 | 11,753,867,483 | 3.6% | ||
pipokinha | 0 | 1,666,328,492 | 4.8% | ||
velourex | 0 | 16,779,500,792 | 4.8% | ||
hanshotfirst | 0 | 1,253,054,214,191 | 25% | ||
lordvader | 0 | 287,962,088,557 | 100% | ||
alaqrab | 0 | 2,949,929,103 | 2.4% | ||
holoz0r | 0 | 1,780,792,538 | 0.48% | ||
lk666 | 0 | 1,556,347,008 | 2.4% | ||
anomaly | 0 | 114,170,929 | 1% | ||
develcuy | 0 | 600,744,417 | 4.8% | ||
curie | 0 | 1,565,130,237,667 | 4.8% | ||
hendrikdegrote | 0 | 66,086,616,226 | 4.8% | ||
slider2990 | 0 | 3,460,881,549 | 4.8% | ||
vact | 0 | 95,731,712,539 | 4.8% | ||
dropahead | 0 | 1,751,541,334 | 4.8% | ||
da-dawn | 0 | 5,694,645,791 | 15% | ||
gmedley | 0 | 985,246,246 | 2.4% | ||
theregularguy | 0 | 154,672,984,179 | 100% | ||
calypso | 0 | 238,640,003 | 100% | ||
brahma | 0 | 273,839,462,161 | 100% | ||
federacion45 | 0 | 4,090,113,459 | 4.8% | ||
arnel | 0 | 706,936,992 | 2.4% | ||
vannfrik | 0 | 5,428,260,657 | 5% | ||
iansart | 0 | 2,874,005,053 | 2.64% | ||
forykw | 0 | 5,443,318,167 | 2.4% | ||
bitrocker2020 | 0 | 2,222,938,102 | 0.24% | ||
jiujitsu | 0 | 2,389,689,452 | 2.4% | ||
lekang | 0 | 676,466,722 | 2.4% | ||
sustainablyyours | 0 | 121,984,759 | 0.24% | ||
zerotoone | 0 | 885,053,754 | 2.4% | ||
locikll | 0 | 4,074,887,148 | 9.6% | ||
mahdiyari | 0 | 10,065,560,364 | 4.8% | ||
aboutyourbiz | 0 | 1,003,548,230 | 4.8% | ||
jayna | 0 | 823,434,082 | 0.72% | ||
cryptokrieg | 0 | 1,196,825,920 | 4.8% | ||
rival | 0 | 3,005,061,548 | 2% | ||
tensor | 0 | 1,818,496,844 | 2.4% | ||
tngflx | 0 | 1,414,152,298 | 1.44% | ||
flatman | 0 | 1,705,646,610 | 4.8% | ||
allcapsonezero | 0 | 3,719,338,708 | 2.4% | ||
felt.buzz | 0 | 1,382,690,083 | 1.2% | ||
steemwizards | 0 | 1,480,641,146 | 100% | ||
hotsteam | 0 | 1,304,457,061 | 2.4% | ||
neumannsalva | 0 | 1,076,287,204 | 2.4% | ||
stayoutoftherz | 0 | 15,955,213,476 | 1.44% | ||
jimshorts | 0 | 8,503,430,883 | 100% | ||
twoitguys | 0 | 570,017,570 | 2.4% | ||
frankvvv | 0 | 543,014,043 | 2.4% | ||
prapanth | 0 | 656,909,485 | 2.4% | ||
revo | 0 | 13,045,193,307 | 4.8% | ||
nerdnews | 0 | 15,844,713,573 | 100% | ||
honeysara | 0 | 631,164,641 | 1.2% | ||
devcoin | 0 | 514,766,367 | 4.8% | ||
kimzwarch | 0 | 6,390,443,004 | 3% | ||
olusolaemmanuel | 0 | 774,058,975 | 3.36% | ||
massivevibration | 0 | 3,978,654,474 | 5% | ||
vera-vaders-ea | 0 | 8,519,729,648 | 100% | ||
karaoke1850 | 0 | 40,927,509,275 | 100% | ||
roleerob | 0 | 2,012,495,316 | 0.96% | ||
cryptononymous | 0 | 569,050,854 | 2.4% | ||
buttcoins | 0 | 5,567,854,149 | 0.96% | ||
sayee | 0 | 89,619,460,580 | 100% | ||
peaceandwar | 0 | 746,439,093 | 2.4% | ||
teacherspet | 0 | 19,016,595,279 | 100% | ||
backtomining | 0 | 1,901,629,886 | 2.5% | ||
notb4mycoffee | 0 | 49,358,855,513 | 100% | ||
silverwhale | 0 | 22,538,386,391 | 90% | ||
postpromoter | 0 | 352,754,492,929 | 4.8% | ||
emrebeyler | 0 | 363,394,481,388 | 100% | ||
bluefinstudios | 0 | 635,359,122 | 1.44% | ||
thevillan | 0 | 615,505,163 | 0.48% | ||
nicole-st | 0 | 663,298,666 | 2.4% | ||
jasimg | 0 | 725,920,205 | 2.4% | ||
drmake | 0 | 2,612,358,983 | 2.4% | ||
pechichemena | 0 | 1,521,270,828 | 0.96% | ||
freakerz | 0 | 2,049,663,285 | 100% | ||
ribbitingscience | 0 | 844,787,093 | 2.4% | ||
hanzappedfirst | 0 | 62,493,038,537 | 100% | ||
skycae | 0 | 602,566,467 | 4.8% | ||
itchyfeetdonica | 0 | 1,258,451,841 | 0.24% | ||
weirdnews | 0 | 7,564,335,402 | 100% | ||
kenadis | 0 | 604,169,037 | 2.4% | ||
iqbaladan | 0 | 554,460,503 | 2.4% | ||
punchline | 0 | 230,431,736,960 | 100% | ||
danaedwards | 0 | 543,151,990 | 4.8% | ||
bitcoinportugal | 0 | 425,514,821 | 50% | ||
stahlberg | 0 | 1,063,942,498 | 2.4% | ||
iamjadeline | 0 | 1,367,690,012 | 0.72% | ||
hijosdelhombre | 0 | 1,826,729,236 | 2.4% | ||
shinedojo | 0 | 607,102,347 | 4.8% | ||
safruddin88 | 0 | 250,495,294 | 25% | ||
kylo-ren | 0 | 7,328,823,113 | 100% | ||
josalarcon2 | 0 | 812,681,518 | 4.8% | ||
ideas-abstractas | 0 | 693,204,834 | 4.8% | ||
nwjordan | 0 | 692,179,009 | 4.8% | ||
oghie | 0 | 733,045,041 | 50% | ||
madefrance | 0 | 1,314,326,826 | 2.4% | ||
anikys3reasure | 0 | 690,634,242 | 10% | ||
irgendwo | 0 | 759,512,901 | 1.2% | ||
ivan-g | 0 | 618,960,707 | 2.4% | ||
giovaabbatichio | 0 | 716,502,843 | 4.8% | ||
zipporah | 0 | 1,469,244,442 | 0.96% | ||
cryptofuwealth | 0 | 84,078,557 | 11% | ||
rusli17 | 0 | 77,292,519 | 10% | ||
positiveninja | 0 | 687,980,256 | 2.4% | ||
lordjames | 0 | 3,438,402,442 | 2.4% | ||
bscrypto | 0 | 3,845,642,325 | 2.4% | ||
juli1 | 0 | 222,118,462 | 74% | ||
qberry | 0 | 2,487,821,079 | 2.4% | ||
dearw | 0 | 2,334,543,948 | 2.4% | ||
indigoocean | 0 | 4,258,658,411 | 2.4% | ||
musicvoter | 0 | 5,217,189,939 | 1% | ||
slobberchops | 0 | 38,153,690,160 | 2% | ||
darthgexe | 0 | 5,014,917,400 | 30% | ||
musicvoter2 | 0 | 8,564,397,424 | 1% | ||
evanpetzer | 0 | 2,704,779,875 | 10% | ||
schroders | 0 | 1,806,352,524 | 1.44% | ||
sagesigma | 0 | 252,835,845 | 1% | ||
longer | 0 | 751,033,131 | 50% | ||
blewitt | 0 | 5,856,397,570 | 0.33% | ||
kafupraise | 0 | 104,696,052 | 34% | ||
ilovecryptopl | 0 | 764,645,983 | 3.84% | ||
yomismosoy | 0 | 581,674,573 | 50% | ||
filler | 0 | 48,835,640,156 | 100% | ||
bflanagin | 0 | 1,862,058,253 | 2.4% | ||
lillywilton | 0 | 753,636,980 | 20% | ||
goblinknackers | 0 | 32,365,218,340 | 3% | ||
gpcx86 | 0 | 117,610,213 | 1% | ||
jk6276 | 0 | 2,530,903,779 | 6% | ||
yaelg | 0 | 2,559,823,736 | 5% | ||
kylealex | 0 | 4,577,161,552 | 10% | ||
hanshotfirst-sm | 0 | 7,496,394,922 | 100% | ||
laissez-faire | 0 | 36,947,578 | 100% | ||
the.success.club | 0 | 2,124,739,661 | 2.4% | ||
chickenmeat | 0 | 833,767,762 | 2.4% | ||
javier.dejuan | 0 | 1,094,402,201 | 4.8% | ||
bernardwest | 0 | 2,364,205,825 | 9.6% | ||
tommyl33 | 0 | 593,797,619 | 2.4% | ||
adalger | 0 | 1,761,467,600 | 0.72% | ||
ppss | 0 | 5,346,566,655 | 4.7% | ||
healthexpert | 0 | 9,089,359,706 | 2.4% | ||
travisung | 0 | 13,638,069,998 | 2.4% | ||
goodcontentbot | 0 | 53,751,027 | 50% | ||
herculean | 0 | 52,360,597 | 50% | ||
pulleyhead | 0 | 1,121,741,400 | 4.8% | ||
chrisluke | 0 | 172,960,006 | 26% | ||
kryptogames | 0 | 18,828,020,489 | 2.4% | ||
sumotori | 0 | 711,350,722 | 75% | ||
brendanweinhold | 0 | 119,490,894 | 100% | ||
knifer | 0 | 574,819,921 | 100% | ||
begood2me | 0 | 733,549,166 | 2.4% | ||
epicdice | 0 | 21,137,726,711 | 1.44% | ||
thetechspot | 0 | 153,650,198 | 26% | ||
phctop3 | 0 | 2,422,160,329 | 1.92% | ||
neoxiancity | 0 | 2,015,850,787 | 20% | ||
poppie-schultz | 0 | 94,182,219 | 10% | ||
slobberchops.tri | 0 | 0 | 5% | ||
steem.consultant | 0 | 866,613,681 | 0.96% | ||
suiku | 0 | 283,839,513 | 8% | ||
lemeonna | 0 | 280,971,022 | 6% | ||
bilpcoinrecords | 0 | 1,096,021,946 | 2% | ||
thebilpcointrain | 0 | 60,742,966 | 1% | ||
bilpcoin.pay | 0 | 146,353,899 | 1% | ||
lusce | 0 | 3,261,909,702 | 10% | ||
steemlondon | 0 | 1,173,317,965 | 3% |
How come this outputs with 0? def print_nums(x): for i in range(x): print(i) return print_nums(10)
author | emrebeyler |
---|---|
permlink | q041dt |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 00:29:54 |
last_update | 2019-10-29 00:29:54 |
depth | 1 |
children | 3 |
last_payout | 2019-11-05 00:29:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 100 |
author_reputation | 448,535,049,068,622 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 91,996,464 |
net_rshares | 5,577,140,777 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ismailkah | 0 | 5,577,140,777 | 25% |
> return is a construction used in the code block of a function definition + after the return instruction is inserted the code block will stop executing anything so : > def print_nums(x): for i in range(x): print(i) return print_nums(10) > Program takes 0, verifies that is in range of 10 and prints 0 Because of the return statement program stops executing the code > If return is deleted from code the output will be 0 1 2 3 4 5 6 7 8 9
author | filler |
---|---|
permlink | q04d3d |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 04:42:54 |
last_update | 2019-10-29 04:42:54 |
depth | 2 |
children | 2 |
last_payout | 2019-11-05 04:42:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 453 |
author_reputation | 4,924,532,976,740 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 92,000,955 |
net_rshares | 0 |
That depends on the indentation:-)
author | emrebeyler |
---|---|
permlink | q04iem |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 06:37:36 |
last_update | 2019-10-29 06:37:36 |
depth | 3 |
children | 1 |
last_payout | 2019-11-05 06:37:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 34 |
author_reputation | 448,535,049,068,622 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 92,002,759 |
net_rshares | 5,554,864,179 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ismailkah | 0 | 5,554,864,179 | 25% |