# New to Python (learning functions)

**URL:** <https://discuss.python.org/t/new-to-python-learning-functions/23542>\
**Category:** Python Help\
**Tags:** help, new-users\
**Created:** [February 5, 2023, 12:05am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542 "2023-02-05T00:05:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moogl3y](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Moogl3y](https://discuss.python.org/u/Moogl3y)\
**Post date:** [February 5, 2023, 12:05am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/1 "2023-02-05T00:05:14Z")

</div>

learning python and have been utilizing HackinScience, but I have been stumped on this question. Any suggestions on what I am doing incorrectly?

 ![python](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/a/ad4d4faa7143222dd3ac8c82008f12e44f6b7c10.png)

---

<div class="post-metadata">

**Author:** ![rob42](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rob42/32/8218_2.png) [@rob42](https://discuss.python.org/u/rob42)\
**Post date:** [February 5, 2023, 12:21am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/2 "2023-02-05T00:21:48Z")

</div>

Hey there.

So, `radius = float()` what? You need to give it a number. Then call your function from within the `print()` function call.

Here is a very simple example:

```python
def greet(name):
    response = f"Hello {name}. How are you?"
    return response

name = input("What is you name? ")

print(greet(name))

```

---

<div class="post-metadata">

**Author:** ![PythonCHB](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pythonchb/32/2551_2.png) [@PythonCHB](https://discuss.python.org/u/PythonCHB)\
**Post date:** [February 5, 2023, 12:36am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/3 "2023-02-05T00:36:46Z")

</div>

the line:

```auto
radius = float

```

you are setting the radius to the `float` type – you want to give it a value – like 1.2 or something.

-CHB

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [February 5, 2023, 12:36am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/4 "2023-02-05T00:36:23Z")

</div>

Hi Lily, and welcome!

Three things you are doing wrong:

(1) Unless you use Photoshop to write your code, you should not post screenshots of code. Copy and paste it as text, between code fences, as described here:

> [@Python Discourse Quick Start](https://discuss.python.org/t/python-discourse-quick-start/116#how-do-i-post-code-snippets-error-messages-etc-4):
>
> Python Discourse Help [About](https://discuss.python.org/about)[FAQ](https://discuss.python.org/faq) Keyboard Shortcuts Found in top right “hamburger” menu or press ? How do I bookmark a message? If one clicks the … icon below a message, it is replaced by a flag white_flag and bookmark icons. (The latter looks like a hanging banner, but represents the exposed end of a fabric bookmark.) (Silly to have to do this, but that is another topic.) In any case, click your profile image and the left of the three icons underneath is the bookmark icon. Click that you …

Screen shots make it difficult for us to run your code if we need to, and discriminate against the blind and visually impaired who may be using a screen reader. (Yes, blind programmers exist.)

(2) Don’t make us guess what error you get. Its not always obvious or easy to guess. Copy and paste the entire traceback, if you get one, starting with the line “Traceback…” not just the last error message at the end.

(3) Tell us what result you expected, and what result you got instead.

In this case, I think I can probaby guess what error you are getting. It looks like you are doing this:

```
radius = float

```

and then you will probably get an error similar to:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'type' and 'float'

```

Am I close?

Look at the value of your radius: you set it to `float`. What value do you expect it to have?

`float` is a _type_ or _class_ in Python, that is, it tells you what type of thing a value is. Values can be strings, integers (whole numbers), lists, floats, or many others.

Try setting `radius = 5.2` instead, for example.

---

<div class="post-metadata">

**Author:** ![Moogl3y](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Moogl3y](https://discuss.python.org/u/Moogl3y)\
**Post date:** [February 5, 2023, 1:25am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/5 "2023-02-05T01:25:23Z")

</div>

Apologies 😅 and thank you!  
I have pasted my new code with a value set to radius.

```auto
import math
def circle_perimeter(radius):
    circumference = 2 * math.pi * radius
    return circumference

radius = float(2.5)
circle_perimeter(radius)
print(cirumference)

```

as for the traceback error

```auto
    circumference = 2 * math.pi * radius
TypeError: unsupported operand type(s) for *: 'float' and 'type'

```

---

<div class="post-metadata">

**Author:** ![Moogl3y](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Moogl3y](https://discuss.python.org/u/Moogl3y)\
**Post date:** [February 5, 2023, 1:28am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/6 "2023-02-05T01:28:04Z")

</div>

Thanks Rob!  
I appreciate the example, as I am new and setting sail to learn Python on my own this really helps a lot!!

---

<div class="post-metadata">

**Author:** ![rob42](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rob42/32/8218_2.png) [@rob42](https://discuss.python.org/u/rob42)\
**Post date:** [February 5, 2023, 1:30am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/7 "2023-02-05T01:30:45Z")

</div>

You are most welcome and enjoy the journey. Remember that it’s a marathon, not a sprint and that you’ve made a very good start.

To add: okay, so you’ve set the radius, so now you can do:

```python
print(circle_perimeter(radius))

```

… or…

```python
radius = float(2.5)
rad = circle_perimeter(radius)
print(rad)

```

---

<div class="post-metadata">

**Author:** ![PythonCHB](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pythonchb/32/2551_2.png) [@PythonCHB](https://discuss.python.org/u/PythonCHB)\
**Post date:** [February 5, 2023, 3:33am UTC](https://discuss.python.org/t/new-to-python-learning-functions/23542/8 "2023-02-05T03:33:05Z")

</div>

> [@rob42](#):
>
> `radius = float(2.5)`

`2.5` is a literal for the float of value 2.5 – you con’t need to call float() on it:

`radius = 2.5`

is just fine. The official tutorial is not a bad place tp start:

> **[3. An Informal Introduction to Python](https://docs.python.org/3/tutorial/introduction.html)**
>
> In the following examples, input and output are distinguished by the presence or absence of prompts (\>\>\> and …): to repeat the example, you must type everything after the prompt, when the prompt ap...
