# Creating a grade from a variable

**URL:** <https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [January 2, 2023, 8:14pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680 "2023-01-02T20:14:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradofalltrades](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bradofalltrades/32/129377_2.png) [@bradofalltrades](https://community.thunkable.com/u/bradofalltrades)\
**Post date:** [January 2, 2023, 8:14pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680/1 "2023-01-02T20:14:01Z")

</div>

so im trying to take a single variable and create a graded score based on it

as an example the range would be from under 10 to over 29.

I split that into 5 groups

> = 29 = 5  
> 29-25 = 4  
> 24.99-15 = 3  
> 14.99-10 =2  
> \<=10 =1

the problem I am having is I can not find a math block that allows me to say that if the value of the variable is between 29 and 25 set grade varible to 4

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 2, 2023, 9:58pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680/2 "2023-01-02T21:58:50Z")

</div>

This question came up recently… please see this post and let me know if it answers your question:

> [@How to calculate this formula and display percentage?](https://community.thunkable.com/t/how-to-calculate-this-formula-and-display-percentage/2199065/8):
>
> You’re welcome. Your percent—\>grade question is typically solved with an if/else if/else if… set of blocks. But it can also be solved with a series of stacked if blocks. Create two variables called percent and grade. Set percent to the value you calculated (such as 71%). Then set up this (I’m using sample values… your actual ranges may be different): Edit: Oops! I originally had these in the wrong order. It should be: If percent \<= 100 then set grade to A If percent \< 90 then set grade to B …

---

<div class="post-metadata">

**Author:** ![bradofalltrades](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bradofalltrades/32/129377_2.png) [@bradofalltrades](https://community.thunkable.com/u/bradofalltrades)\
**Post date:** [January 4, 2023, 11:16pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680/3 "2023-01-04T23:16:20Z")

</div>

i was able to come up with this solution, and it works fine for what I need. what tripped me up was that I did not find a math block to give a set range between two numbers to pair with the if-then block

 ![grade](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/9/395626aa1a81fdafc7e2653b56e9904c4573c08f.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 4, 2023, 11:38pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680/4 "2023-01-04T23:38:10Z")

</div>

Right, there isn’t a “range” block so that’s the solution I typically use. You can, if you want, create a range with the AND (logic) block. So you could say if app variable grade \>= 0 AND app variable grade \<=10… and that would be the same as 0 \<= x \<=10.

I actually wrote a function in Thunkable a while ago that takes a list of numbers such as 29, 25, 15, 10, 0, and then using a loop creates the conditions for everything you have in your screenshot. It’s pretty hard to wrap your mind around so I don’t recommend it but it is something I can use over and over instead of having to create all of the individual blocks like in your screenshot.

It’s probably not going to make a lot of sense but this is what it looks like:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/c/3cd7d021499ed86f338327851f2f349869b7871b.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f1b3457ff9d5fdf8311a5ca26a538f77953ff6ee.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [April 4, 2023, 11:38pm UTC](https://community.thunkable.com/t/creating-a-grade-from-a-variable/2201680/5 "2023-04-04T23:38:41Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
