## 13 Examples in Python

2013/04/19 Good I leave some basic exercises them in python, if it has some doubt or some of the exercises has an error simply comment it.

Them memory that do not copy first solves by you same and soon they can consults for knowing as it solves the problems, I hope that it serves to them as aid until the next one!

1. To request two numbers and to say if they are equal or no.

```first = input () secondly = input () if (first == secondly):
print (“if he is equal�?) else:
print (“he is not equal�?)```

2. To request a number and to indicate if he is positive or negative.

```I number = input () if (I number > 0):
print (“he is positive�?) else:
print (“he is negative�?)```

3. To request two numbers and to say if one is multiple of the other.

```numero01 = input () numero02 = input () if (numero01%numero02==0):
print (“he is multiple�?) else:
print (“he is not multiple�?)```

4. To request two numbers and to say which is the major.

```numero01 = input (“Peru�?) numero02 = input (“Chile�?) if (numero01 > numero02):
print (“Peru is major that Chile�?) elif numero02>numero01:
print (“Chile is major that Peru�?) elif (numero01 == numero02):
print (“they are equal�?)```

5. To request two numbers and to say which is the major or if they are equal.

```numero01 = input (“Peru�?) numero02 = input (“Chile�?) if (numero01 > numero02):
print (“Peru is major that Chile�?) elif numero02>numero01:
print (“Chile is major that Peru�?) elif (numero01 == numero02):
print (“they are equal�?)```

6. To request two numbers and to show ordered them from largest to smallest.

```numero01 = input () numero02 = input () if (numero01>numero02):
print numero01, “and�?, numero02 else:
print numero02, “and�?, numero01```

7. To request three numbers and to show ordered them from largest to smallest.

```numero01 = input () numero02 = input () numero03 = input () if (numero01>numero02>numero03):
print numero01, “and “, numero02,�? and “, numero03 elif (numero01>numero03>numero02):
print numero01, “and “, numero03,�? and “, numero02 elif (numero02>numero01>numero03):
print numero02, “and “, numero01,�? and “, numero03 elif (numero02>numero03>numero01):
print numero02, “and “, numero03,�? and “, numero01 elif (numero03>numero01>numero02):
print numero03,�? and “, numero01,�? and “, numero02```

8. To request a note from 0 to 10 and to show it of the form: “Insufficient�?, “Sufficient�?, “Well�?. From 0 to 3 he will be “insufficient�?, of 4 to 6 “Sufficient�? and from 6 to 10 “Good�?.

```note = input () if (note <= 3):
print “insufficient�? elif (note <= 6):
print “Sufficient�? elif (nota<=10):
print “Well�?```

9. To request the day, month and year of a date and to indicate if the date is correct. Supposing every month of 30 days.

```day = input (“day 1: �?) month = input (“month 1: �?) ao = input (“year 1: �?) if (day >=1 and day <= 30):
if (month >=1 and month <= 12):
if (ao! = 0):
print “CORRECT DATE�?
pass else:
print “date incorecto�?```

10. To request two dates and to show the number of days that there are of difference. Supposing every month of 30 days.

`dia1 = input (“day 1: �?) mes1 = input (“month 1: �?) año1 = input (“year 1: �?) dia2 = input (“day 2: �?) mes2 = input (“month 2: �?) año2 = input (“year 2: �?) day = (dia2-dia1) + 30* (mes2-mes1) + 365 (año2-año1) print “Total of day are: �? day`

11. To request an integral number between 0 and 10, and to show this number of the form: “zero�?, “one�?, “two�?, “three�?…

```I number = int (input (“it enters from the 1 to the 10�?))
if (numero==1):
print “one�? elif (numero==2):
print “two�? elif (numero==3):
print “tress�? elif (numero==4):
print “four�? elif (numero==5):
print “five�? elif (numero==6):
print “seiss�? elif (numero==7):
print “sieree�? elif (numero==8):
print “ochoo�? elif (numero==9):
print “nueee�? elif (numero==10):
print “ten�?```

12. To request 3 numbers and to calculate the sum and multiplication between the three numbers.

`num1 = input () num2 = input () num3 = input () suma=num1+num2+num3 multi=num1*num2*num3 print “sum�?, sum print “multipicacion�?, multi`

13. To request 10 numbers, and that the program says whichever entered numbers to me they were negative.

```I number = 0 negative = 0 negative friend =0 while! =10:
I number = input (“enters I number: �?)
negative = negative +1
if numero<0:
friend = friend +1 print “negative numbers: �?, friend```

15, For example if the user enters of month the program will say that there is error because they do not exist more than 12 months. If it enters negative numbers also will give error.

```day = input (“day 1: �?) month = input (“month 1: �?) ao = input (“year 1: �?) if (day >=1 and day <= 30):
if (month >=1 and month <= 12):
if (ao! = 0):
print “CORRECT DATE�?
pass else:
print “incorrect date�?```