Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form
Python Programming

Write a program that asks user their name and gender, and displays on the screen | Python Programming | Conditional Structure Exercises

Posted on June 12, 2022June 12, 2022 By myustaadg.com

Conditional Structure Exercises in Python Programming

Python Programming

The students of a course have been divided into two groups A and B according to sex and name. Group A consists of women with a name before M and men with a name after N and group B for the rest. Write a program that asks the user their name and gender, and displays on the screen the group that corresponds to them.

Solution:

Code:

name = input("What's your name? ")
gender = input("What is your sex (M or H)? ")
if gender == "M":
    if name.lower() < "m":
        group = "A"
    else:
        group = "B"
else:
    if name.lower() > "n":
        group = "A"
    else:
        group = "B"
print("Your group is" + group)
Click Here For Direct Solution on Colab

#colab

#Python Programming Importance

Hope You will learn Something. Happy Coding

Programming Exercises, Python Exercises Tags:and displays on the screen the group that corresponds to them., conditional exercises, conditional statment solved exerciese in python, conditional statments, conditional statments in python, conditional Structure, conditional structure codes in python, conditional structures in python, easy python lectures, easy python tutorials, python lectures, python programming, python programming tutorials, pyton lectures for beginner, Write a program that asks the user their name and gender, Write a program that asks the user their name and gender and displays on the screen the group that corresponds to them in python, Write a program that asks the user their name and gender and displays on the screen the group that corresponds to them in python programming

Post navigation

Previous Post: Write a program that asks the user their annual income and shows on the screen the tax rate that corresponds to them | Python Programming | Conditional Structure Exercises
Next Post: Write a program which input age from user and display on the screen if he/she is of legal age or not | Python Programming | Conditional Structure Exercises

More Related Articles

Write a function, and a program to test it, that will place a zero in each element of array passed to it from the calling program. Arrays Exercises
Write a program that inputs real values into float type array. It reads the value of each element of float type array and assigns to int type array. Arrays Exercises
Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen. Arrays Exercises
Write a Program that Inputs Values into an Array and Displays the Values of the Array Arrays Exercises
Write a program that uses three one-dimensional arrays and inputs 20 values in 1st array and differentiates even and odd values. Arrays Exercises
Write a program that inputs marks of N students and finds out the grade of each student. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme