Ask coding questions

← Back to all posts
Can someone help me with that code?
Mariamalrashdi (0)

Creating a program

Write a Python program as below algorithm

  1. Enter 3 subjects as follow (English, Maths, Computer Science)
  2. Change all subjects data to integers - int
  3. Check if English is Greater than 95 AND Computer Science is Greater than 92
    Then print ("You are ASP Cluster")
  4. Check if Maths is Greater than 90 OR Computer Science is Greater than 92
    Then print ("You care CAI Cluster")
  5. If all marks do not match conditions
    Then print ("You are AE Cluster")
Comments
hotnewtop
19ecal (228)

Now I could straight up give you the code, but instead here are some pointers
To take input in python, you do

data=input("Enter some data")

That will print Enter some data, and then whatever you enter will be saved in the variable data

To convert from a string to an integer we can do

#string is a variable with "42" in it
string="42"
#number is a variable with 42 in it
number=int(string)

So long as your string is a string value of a number, int() will convert to an integer.

To do ifs in python, we do

data=10
more_data=90

if data>20 and more_data>50:
  #this won't run
  print("data is more than 20 and more_data is also more than 50")
elif data<20 or more_data>95:
   #this will run 
   print("either data is less than 20 or more_data is more than 95")
#if none of the above conditions are met
else:
   #this won't run
   print("nothing was met :(")

Hopefully that should help, if you need any more just reply to this comment

Mariamalrashdi (0)

Thank you I understand, but can you give me the code please🙏🏻@19ecal

19ecal (228)

@Mariamalrashdi Have you tried to write something with the information I gave you?

Mariamalrashdi (0)

I got it somthing like that
English = input("enter English mark")
English = int(English)
Math = input("enter Math mark")
Math = int(Math)
Computer = input("enter Computer mark")
Computer = int(Computer)
if English > 95 and Computer > 92:
print("You are ASP Cluster")
elif Math > 90 or Computer > 92:
print ("You are CAI Cluster")
else:
print("You are AE Cluster")
@19ecal

19ecal (228)

@Mariamalrashdi That should work as long as you remember to indent after the ifs like this

data=45
more_data=90
if data>50 and more_data<80:
    #There are 4 spaces in front of this line
    #That tells Python that this is what we want it to do if the condition is met
    print("condition met")

Also, remember you can put you code inside 3 backticks to format it as code when you're using repl.it talk
Here's some more information about that

IMayBeMe (344)

Are you looking to find their Unicode values cause otherwise converting a string to an int would be impossible. So could you please give a little bit more info on how you are planning to achieve this?

IMayBeMe (344)

@Mariamalrashdi You can covert it to Unicode by using the ord() function to find the values.

RYANTADIPARTHI (6001)

what have you tried first?