Showing posts with label Conditional Statement. Show all posts
Showing posts with label Conditional Statement. Show all posts

Python : Conditional Statement Test 7

 

 

Python : Conditional Statement Test 7


Q1. Evaluate the following statements:

 

a=True

b=True

c=True

d=True

 

1.          print(c)
2.          print(d)
3.          print(not a)
4.          print(not b )
5.          print(not c )
6.          print(not d)
7.          print(a and b )
8.          print(a or b )
9.          print(a and c)
10.       print(a or c )
11.       print(a and d )
12.       print(a or d)
13.       print(b and c )
14.       print(b or c )
15.       print(a and b or c)
16.       print(a or b and c )
17.       print(a and b and c)
18.       print(a or b or c )
19.       print(not a and b and c)
20.       print(not a or b or c )
21.       print(not (a and b and c))
22.       print(not (a or b or c) )
23.       print(not a and not b and not c)
24.       print(not a or not b or not c )
25.       print(not (not a or not b or not c))

SOLUTIONS
 
  1.  True
  2. True
  3. False
  4. False
  5. False
  6. False
  7. True
  8. True
  9. True
  10. True
  11. True
  12. True
  13. True
  14. True
  15. True
  16. True
  17. True
  18. True
  19. False
  20. True
  21. False
  22. False
  23. False
  24. False
  25. True

Python : Conditional Statement Test 6

  

Python : Conditional Statement Test 6

Q1. Accept three numbers from the user and display the second largest number.

Q2. Accept three sides of triangle and check whether the triangle is possible or not.

(triangle is possible only when sum of any two sides is greater than 3rd side)

Q3. Consider the following code

                                  

What will the above code print if the variables i, j, and k have the following values?

(a)    i = 3, j = 5, k = 7

(b)    i = -2, j = -5, k = 9

(c)    i = 8, j = 15, k = 12

(d)    i = 13, j = 15, k = 13

(e)    i = 3, j = 5, k = 7

(f)    i = 3, j = 5, k = 7

Q4. Accept the electric units from user and calculate the bill according to the following rates.

First 100 Units    :  Free

Next 200 Units     :  Rs 2 per day.

Above 300 Units    :  Rs 5 per day.

Q5. Accept the number of days from the user and calculate the charge for library according to following :

First five days : Rs 2/day.

Six to ten day  : Rs 3/day.

Ten to 15 days  : Rs 4/day

After 15 days   : Rs 5/day

Q6. Accept the kilometers covered and calculate the bill according to the following criteria:

First 10 Km             Rs11/km

Next 90Km               Rs 13/km

After that              Rs15/km

Q7. Accept the marks of English, Math and Science, Social Studies Subject and display the stream allotted according to following

All Subjects more than 80 marks --      Science Stream

English >80 and Math, Science above 50 --Commerce Stream

English > 80 and Social studies > 80    --  Humanities

Python : Conditional Statement Test 5

 

Python : Conditional Statement Test 5

Q1. Accept the following from the user and 

    calculate the percentage of class attended:

a.     Total number of working days

b.     Total number of absent

    If the percentage is less than 75, than            student will not be able to sit in exam.

Q2. Accept the marks from the user and display the

    grade according to the following criteria:

    a. Below 25 - D

    b. 25 to 45 - C

    c. 45 to 50 - B

    d. 50 to 60 – B+

    e. 60 to 80 - A

    f. Above 80 – A+

Q3. A company decided to give bonus to employee 

    according to following criteria:

    Year of Service               Bonus

    More than 10 years            10%

    >=6 and <=10                  8%

    Less than 6 years             5%

    Ask user for their salary and year of service     and print the net bonus amount.

Q4. Accept the marked price from the user and 

    calculate the Net amount as(Marked Price –

    Discount) to pay according to following 

    criteria:

Marked Price

Discount

>10000

20%

>7000 and <=1000

15%

<=7000

10%

 

Q5. Write a program to accept percentage and

    display the Category according to the

    following category :

Per

Category

< 40

Failed

>=40 & <55

Fair

>=55 & <65

Good

>=65

Excellent

 

Q6. Accept three sides of a triangle and check 

    whether it is an equilateral, isosceles or 

    scalene triangle.

Note :

An equilateral triangle is a triangle in which all three sides are equal.

A scalene triangle is a triangle that has three unequal sides.

An isosceles triangle is a triangle with (at least) two equal sides.

Q7. Write a program to accept two numbers and 

    mathematical operators and perform operation 

    accordingly.

Like:

Enter First Number: 7

Enter Second Number : 9

Enter operator : +

Your Answer is : 16

Q8. Accept the age, sex (‘M’, ‘F’), number of days

    and display the wages accordingly

Age

Sex

Wage/day

>=18 and <30

M

700

F

750

>=30 and <=40

M

800

F

850

If age does not fall in any range then display the following message:

“Enter appropriate age”

 

Python : Conditional Statement Test 4

 

Python : Conditional Statement Test 

Q1. Accept the temperature in degree Celsius of

    water and check whether it is boiling or

    not (boiling point of water in 100 oC.

Q2. _________ is a graphical representation of

    steps (algorithm/flow chart)

Q3.python has _________ statement as empty

   statement (Pass/Fail)

Q4. In python, a block is a group of _______

    statement having same indentation level

    (consecutive/alternate)

Q5. Out of “elif” and “else if”, which is the

    correct statement in python?

Q6. What is the difference between break and

    continue statements?

Q7. What is the purpose of else in if elif

    ladder?

Q8. Accept the age of 4 people and display the

    oldest and youngest one.

Q9. Write a program to check whether a number

    is prime or not.

Q10. Write a program to check a character is

     vowel or not.

Python : Conditional Statement Test 3

 

Python : Conditional Statement Test 3

Q1. Write a program to check a year is leap year 

    or not.

Q2. Write a program to check whether a person is

    eligible for voting or not.(voting age >=18)

Q3. Write a program to check whether a person is 

    senior citizen or not.

Q4. Write a program to find the lowest number out 

    of two numbers excepted from user.

Q5. Write a program to find the largest number out

    of two numbers excepted from user.

Q6. Write a program to check whether a number 

    (accepted from user) is positive or negative.

Q7. Write a program to check whether a number is 

    even or odd.

Q8. Write a program to display the spell of a 

    digit accepted from user (like user input 0 

    and display ZERO and so on)

Q9. Write a program to whether a number (accepted 

    from user) is divisible by 2 and 3 both.

Q10. Write a program to find the largest number 

     out of three numbers excepted from user.

Python : Conditional Statement Test 2

Q1. Write a program to accept percentage from the user and display the grade according to the following criteria:

                    Marks                                    Grade

                    > 90                                        A

                   >80 and <=90                          B

                   >=60 and <80                          C

                   below 60                                  D

Q2. Write a program to accept the cost price of a bike and display the road tax to be paid according to the following criteria :

                                   

Q3. Write a program to check whether an years is leap year or not.

Q4. Write a program to accept a number from 1 to 7 and dsplay the name of the day like 1 for Sunday , 2 for monday and so on.

Q5. Write a progam to accept a number from 1 to 12 and display name of the month and days in that month like 1 for january and number of days 31 .......

Q6. What do you mean by statement?

Q7. Write the output of the following:
                    if True:
                        print(101)
                    else:
                        print(202)
Q8. Write the logical expression for the following:
  1. A is greater than B and C is greater than D
Q9. Accept any city from the user and display monument of that city
                        
Q10. Write the output of the following if a = 9
            if (a > 5 and a <=10):
                print("Hello")
            else:
                print("Bye")

Python - Conditional Statement Test 1

 Q1. Name the keyword which helps in writing code involves condition.

Q2. Write the syntax of simple if statement.

Q3. Is there any limit of statement that can appear under an if block.

Q4. Write a program to check whether a person is eligible for voting or not. (accept age from user)

Q5. Write a program to check whether a number entered by user is even or odd.

Q6. Write a program to check whether a number is divisible by 7 or not.

Q7. Write a program to display "Hello" if a number entered by user is a multiple of fie , otherwise print "Bye".

Q8. Write a program to calculate the electricity bill according to the following criteria :

                    unit                                price

                    First 100 units -----------no charge

                    Next 100 units ----------Rs 5 / unit

                    Next units ---------------Rs 10/unit

(For example if input unit is 350 than total bill amount is Rs2000)

Q9. Write a program to display the last digit of a number.

(hint : any number % 10 will retun the last digit)

Q10. Write a program to check whether the last digit of a number( entered by user ) is divisible by 3 or not.

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet