Python Programming Tutorial - 14 - Default Values for Arguments

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

You should make more challenges, even if you have already covered a section. What I mean is come up with some practice problems for like every other tutorial and post them to your forum. I feel that would be immensely helpful to a lot of people, myself included. But seriously dude, great tutorials, thanks for putting your time and effort into these, it shows. Thanks man!

ProPMartin
Автор

My name is Credible, ....Justin Credible.

MadmanBTS
Автор

Do you know what mistake Bukcy made in the previous video?
He tried to fuse dating with programming,
and that led to a huge drop in the views.
After all, who wants to face arguments when they are dating?

modernwarrior
Автор

Python has changed since Bucky made this tutorial. I couldn't get this to work properly with the code as given. I got help from AI which came up with this which also solves the problem of someone entering some random character(s) other than m or f:

def get_gender(sex='Unknown'):
"""
Returns the gender string based on the input sex code.

Args:
sex (str, optional): A single character code representing gender. Defaults to 'Unknown'.

Returns:
str: The gender string ('Male', 'Female', or 'Unknown').
"""

if sex == 'm':
return 'Male'
elif sex == 'f':
return 'Female'
else:
return 'Unknown'

print(get_gender('m')) # Output: Male
print(get_gender('f')) # Output: Female
print(get_gender()) # Output: Unknown
print(get_gender('dog')) #Output: Unknown

FilmsbytheYear
Автор

What do you call a person who arrives exactly on time?
Justin Time!
(Just made it up mahself.)

seanbrown
Автор

* NEWSCAST! *
This Justin! I thought of a joke.

DeadlyCicada
Автор

thanks for videos, I've tried to learn python with other videos but I understand it much better with yours, so far

richmedia
Автор

There is minor issue with the use of the is operator for string comparison. When comparing strings, you should use the equality operator == instead of "is"

nurbolsatibaldiev
Автор

You assumed that there are only 2 genders?!
*TRIGGERED*

rctvids
Автор

Found an issue with this code when trying to break it
if you enter some that is not ('m'), ('f') or ()
then you'll get a value that can be anything
for instance:
get_gender('Alien')
will print out "Alien"

this can be fixed by adding the following else statement to the function

else:
sex = "Unknown"

CaptinDread
Автор

great job, I just wish you zoomed in. It's kind of hard to see all in one screen while taking notes

elysel
Автор

for X in range(15, 61):
Y=X/2+7
print("So the girl's age that you can date is ", Y, "and you are ", X, "\n")

rohankucheriya
Автор

def date(my_age):
girls_age = my_age / 2 + 7
return girls_age


for x in range(15, 80):
age = date(x)
print(x, "-->", age)

trailmusic
Автор

Thank you so much for making these tutorials!

azory
Автор

I have given space between string in if condition. here goes the code
if order is '5% less':
order="give discount"
elif order is '5% less':
order="no discount"
print(order)

get_det('5% less')

just because it had space between strings it was returning 5% less in output instead of actual no discount.

Solitary
Автор

justin case you don't have a joke Justin time, no worries Justin will tell a Justin joke for you

DigitalDivotGolf
Автор

Here the code

def limit(age):
g_limit=age/2+7
return g_limit

for n in range (10, 50):
max=limit(n)
print("The Minimum age of Girl to date is ", max, " for a ", n, "years Boy.")

srivenkatesh
Автор

What's the best name for a backup goalie?

Justin Case

AddAHandleContinue
Автор

whats the difference between using is and ==?

__dam__
Автор

def age_limit(age):
age_lim = age/2 + 7
return age_lim
for n in range(15, 30):
print(n)
print(age_limit(n));

sa