{"id":15797401,"url":"https://github.com/devqueue/class-12-python","last_synced_at":"2025-07-29T00:38:13.073Z","repository":{"id":126913474,"uuid":"309416007","full_name":"devqueue/Class-12-python","owner":"devqueue","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-16T13:20:28.000Z","size":6706,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T00:30:56.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devqueue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-02T15:41:43.000Z","updated_at":"2020-12-16T13:20:30.000Z","dependencies_parsed_at":"2023-06-18T21:36:00.666Z","dependency_job_id":null,"html_url":"https://github.com/devqueue/Class-12-python","commit_stats":{"total_commits":54,"total_committers":1,"mean_commits":54.0,"dds":0.0,"last_synced_commit":"e2d924fdd71758c193d0f59cf43a04c97bb53067"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devqueue/Class-12-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devqueue%2FClass-12-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devqueue%2FClass-12-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devqueue%2FClass-12-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devqueue%2FClass-12-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devqueue","download_url":"https://codeload.github.com/devqueue/Class-12-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devqueue%2FClass-12-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267610605,"owners_count":24115442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T00:07:49.245Z","updated_at":"2025-07-29T00:38:13.008Z","avatar_url":"https://github.com/devqueue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#                    Program - Class 12\n\nAuthor: Hazique sayyed\n\n\u003ch1 align=\"center\"\u003ePYTHON\u003c/h1\u003e\n\n### Program 1\n##### Aim: To write a simple calculator to find sum, diference, product and division \n#### Source code: \n``` python\ndef add(x, y):\n    return x + y\n\ndef subtract(x, y):\n    return x - y\n\ndef multiply(x, y):\n    return x * y\n\ndef divide(x, y):\n    return x / y\n\nprint(\"Select operation.\")\nprint(\"1.Add\")\nprint(\"2.Subtract\")\nprint(\"3.Multiply\")\nprint(\"4.Divide\")\n\nwhile True:\n    choice = input(\"Enter choice(1/2/3/4): \")\n    if choice in ('1', '2', '3', '4'):\n        num1 = float(input(\"Enter first number: \"))\n        num2 = float(input(\"Enter second number: \"))\n\n        if choice == '1':\n            print(num1, \"+\", num2, \"=\", add(num1, num2))\n\n        elif choice == '2':\n            print(num1, \"-\", num2, \"=\", subtract(num1, num2))\n\n        elif choice == '3':\n            print(num1, \"*\", num2, \"=\", multiply(num1, num2))\n\n        elif choice == '4':\n            print(num1, \"/\", num2, \"=\", divide(num1, num2))\n        break\n    else:\n        print(\"Invalid Input\")\n```\n#### Output: \n\n![](media/program1_out.png)\n\n\n\n\n---\n### Program 2\n#### AIM: To write a random number generator that generates random numbers between 1 and 6 \n#### Source code:\n``` Python\nimport random\na = random.randint(1, 6)\nprint(f\"Dice rolls {a}\")\n```\n\n#### Output: \n\n\n![](media/program2_out.png)\n\n---\n### Program 3\n#### AIM: To write a Python program to read a text file ( story.txt) line by line and print it.\n#### Source code:\n``` python\nstory = \"story.txt\"\nwith open(story, \"r\") as f:\n    lines = f.readlines()\n    for line in lines:\n        print(line)\n```\n\n#### Output: \n\n\n![](media/program3_out.png)\n\n\n---\n### Program 4\n#### AIM: To Write a Python program to read a text file and remove all the lines that contains the character ‘a’ in the file and write it in another file\n#### Source code:\n```python\noldfile = open('content.txt')\nlines = oldfile.readlines()\nnewopen = open('newfile.txt', 'w')\n#print(lines)\n\nfor line in lines:\n    if 'a' in line:\n        #print(line)\n        line = line.replace(line, '')\n    else:\n        newopen.write(line)\nnewopen.close()\noldfile.close()\nprint(\"Contents copied over to newfile.txt\")\n```\n#### Output: \n\n\n![](media/program4_out.png)\n\n\n---\n\n### Program 5\n#### AIM: To write a Python program to read a text file line by line and display each word seperated by a #.\n#### Source code:\n```python\nwith open('story.txt', 'r') as f:\n    for line in f:\n        for word in line.split():\n            print(word, end=\"#\")\n    print('\\n')\n```\n\n#### Output: \n\n![](media/program5_out.png)\n\n\n---\n### Program 6\n#### AIM: To Write a Python program to read a text file line by line and display the number of vowels/ consonants / upper case letters and lower case characters.\n#### Source code:\n```python\nvowels = ['a','e','i','o','u']\nvowels_count = 0\nconsonat_count = 0\nupper_count = 0\nlower_count = 0\n\n\nfile = open('story.txt', 'r')\ndata = file.read()\nprint(data)\nfor ch in data:\n    if str.isupper(ch):\n        upper_count += 1\n    elif str.islower(ch):\n        lower_count += 1\n    ch2 = str.lower(ch)\n    if ch2 in vowels:\n        vowels_count+=1\n    elif ch2 not in vowels:\n        consonat_count+=1\n\nprint(f\"No. of vowels are {vowels_count}\")\nprint(f\"No. of vowels are {consonat_count}\")\nprint(f\"No. of vowels are {upper_count}\")\nprint(f\"No. of vowels are {lower_count}\")\nfile.close()\n```\n\n#### Output: \n\n![](media/program6_out.png)\n\n\n---\n\n### Program 7\n#### AIM: To Write a Python program to create a binary file with name and roll number. Search for a given roll number and display the name, if not found , display appropriate message\n#### Source code:\n```python\nimport pickle\nimport sys\nimport pprint as pp\ndict= {}\n\ndef write_in_file():\n    file = open(\"Student.pickle\", \"ab\")\n    dict[\"Roll\"] = int(input(\"Enter the Roll NO: \"))\n    dict[\"Name\"] = input(\"Enter a name: \")\n    pickle.dump(dict, file)\n    file.close()\n\ndef display():\n    file = open(\"Student.pickle\", 'rb')\n    try:\n        while True:\n            Student = pickle.load(file)\n            pp.pprint(Student)\n    except EOFError:\n        pass\n    file.close()\n\n\ndef search():\n    file = open(\"Student.pickle\", 'rb')\n    reader = int(input(\"Enter the Roll No. to search: \"))\n    found = False\n    try:\n        while True:\n            data = pickle.load(file)\n            if data[\"Roll\"] == reader:\n                print(\"Record Found\")\n                print(data)\n                found = True\n                break\n    except EOFError:\n        pass\n    if found==False:\n        print(\"Record not found \\n \\n\")\n    file.close()\n\n\n#main program\nwhile True:\n    print(\"Menu \\n 1-Write in a file \\n 2-display \\n 3-Search \\n 4-exit \\n\")\n    ch = int(input(\"Enter a Choice: \"))\n    if ch==1:\n        write_in_file()\n    if ch==2:\n        display()\n    if ch==3:\n        search()\n    if ch==4:\n        sys.exit()\n```\n#### Output: \n\n![](media/program7_out.png)\n\n\n\n---\n### Program 8\n#### AIM: To Write a Python program to create a binary file with roll number , name and marks. Input a roll number and update the marks.\n#### Source code:\n```python\nimport pickle\nimport pprint as pp\nimport sys\n\ndef Display(data):\n    data = {}\n    file = open(\"Student.pickle\", 'rb')\n    try:\n        while True:\n            Student = pickle.load(file)\n            pp.pprint(Student)\n    except EOFError:\n        file.close()\n\ndef Search(data):\n    data = {}\n    file = open(\"Student.pickle\", 'rb+')\n    reader = int(input(\"Enter the Roll No. to search: \"))\n    found = False\n    try:\n        while True:\n            data = pickle.load(file)\n            if data[\"Roll\"] == reader:\n                print(\"Record Found\")\n                print(data)\n                found = True\n                break\n    except EOFError:\n        if found == False:\n            print(\"Record not found \\n \\n\")\n        file.close()\n\ndef write_in_file(data):\n    data = {}\n    studs = int(input(\"Enter no. of students: \"))\n    file = open(\"Student.pickle\", \"rb+\")\n    for i in range(1,studs+1):\n        data[\"Roll\"] = int(input(\"Enter the Roll NO: \"))\n        data[\"Name\"] = input(\"Enter a name: \")\n        data[\"Marks\"] = float(input(\"Enter the marks: \"))\n        pickle.dump(data, file)\n        print(f\"{i} Record(s) Entered Sucessfully\")\n        data={}\n        \n    file.close()\n\ndef Update_marks(data):\n    data = {}\n    found = False\n    reader = int(input(\"Enter the Roll No. to update: \"))\n    file = open(\"Student.pickle\", 'rb+')\n\n    try:\n        while True:\n            pos = file.tell()\n            data = pickle.load(file)\n            if data[\"Roll\"] == reader:\n                print(\"Record Found\")\n                print(data)\n                data[\"Marks\"] = float(input(\"Enter the marks: \"))\n                file.seek(pos)\n                found = True\n                pickle.dump(data, file)\n                break\n    except EOFError:\n        if found == False:\n            print(\"Record not found \\n \\n\")\n        else:\n            print(\"Marks updated Sucessfully\")\n        file.close()\n\n    \nSdata = {}\n\n#main program\nwhile True:\n    print(\"Menu \\n 1-Write in a file \\n 2-display \\n 3-Search \\n 4-Update Marks \\n 5-exit\")\n    ch = int(input(\"Enter a Choice: \"))\n    if ch == 1:\n        write_in_file(Sdata)\n    if ch == 2:\n        Display(Sdata)\n    if ch == 3:\n        Search(Sdata)\n    if ch == 4:\n        Update_marks(Sdata)\n    if ch == 5:\n        sys.exit()\n\n```\n\n#### Output: \n\n\n![](media/program8_out.png)\n\n\n\n---\n### Program 9\n#### AIM: To Write a Python program which implements a List using a list data-structure.\n#### Source code:\n```python\nimport sys\n\nLIST = []\n\ndef add(index,obj):\n    LIST.insert(index,obj)\n\n\ndef delete(elememt):\n    LIST.remove(elememt)\n\n\ndef search(obj):\n    for i in range(len(LIST)):\n        if LIST[i] == obj:\n            print(f\"Object found at {i} index\")\n\n\nwhile True:\n    print('''\\n1. Insert a value into the LIST\n2. Append a value to the list\n3. Delete a value from the LIST\n4. Display the LIST\n5. Search the LIST for an element \n6. Exit\n    ''')\n    choice = int(input(\"Enter a choice: \"))\n\n\n    if choice == 1:\n        OBJECT = input(\"Element: \")\n        INDEX = int(input(\"Index: \"))\n        add(INDEX,OBJECT)\n\n\n    elif choice == 2:\n        VAR = input(\"Element to append: \")\n        LIST.append(VAR)\n\n\n    elif choice == 3:\n        ELEMENT = input(\"Enter the element to remove: \")\n        try:\n            delete(ELEMENT)\n        except ValueError:\n            print(\"ELement not present in the list\")\n\n\n    elif choice == 4:\n        print(LIST)\n\n\n    elif choice == 5:\n        OBJ = input(\"Enter the element to search: \")\n        search(OBJ)\n\n\n    elif choice == 6:\n        sys.exit()\n```\n\n#### Output: \n\n\n![](media/program9_out.png)\n\n\n---\n### Program 10\n#### AIM: To write a Python program to implement a stack using a list data-structure.\n#### Source code:\n```python\nimport sys\n\nSTACK = []\n\ndef push(element):\n    STACK.append(element)\n\ndef pop():\n    if len(STACK) == 0:\n        print(\"List is empty\")\n    else:\n        c = STACK.pop()\n        print(c)\n\n\ndef display_stack():\n    for i in range(len(STACK)-1, -1, -1):\n        print(STACK[i])\n\nwhile True:\n    print('''\\n1. Push into the STACK\n2. Pop value from the STACK\n3. Display the STACK\n4. Exit\n    ''')\n    choice = int(input(\"Enter a choice: \"))\n    if choice==1:\n        val = input(\"Enter a value: \")\n        push(val)\n    elif choice==2:\n        pop()\n    elif choice==3:\n        display_stack()\n    elif choice == 4:\n        sys.exit()\n```\n\n#### Output: \n\n\n![](media/program10_out.png)\n\n\n---\n### Program 11\n#### AIM: To write a Python program to find the most commonly occuring words in a text file or from sample of ten phising emails.\n#### Source code:\n```python\nwith open(\"email.txt\", \"r\") as f:\n    content = f.read()\n    max = 0\n    max_occuring_word = \"\"\n    occurances_dict = {}\n    words = content.split()\n    for word in words:\n        count = content.count(word)\n        occurances_dict.update({word:count})\n        if count\u003emax:\n            max=count\n            max_occuring_word = word\n    print(f\"Most occuring word: {max_occuring_word}\")\n    print(f\"Frequency of other words {occurances_dict}\")\n```\n\n#### Output: \n\n![](media/program12_out.png)\n\n---\n### Program 12\n#### AIM: To Integrate SQL with Python by importing the MySQL module\n#### Source code:\n```python\nimport mysql.connector as sqltor\nfrom mysql.connector import Error\n\nconnection = sqltor.connect(\n    host='localhost', database='Haziq', user='root', password='\u003cpass\u003e')\ntry:\n    if connection.is_connected():\n        db_Info = connection.get_server_info()\n        print(\"Connected to MySQL Server version \", db_Info)\n        cursor = connection.cursor()\n        cursor.execute(\"select database();\")\n        record = cursor.fetchone()\n        print(\"You're connected to database: \", record)\n\nexcept Error as e:\n    print(\"Error while connecting to MySQL\", e)\nfinally:\n    if (connection.is_connected()):\n        cursor.close()\n        connection.close()\n        print(\"MySQL connection is closed\")\n```\n\n#### Output: \n\n![](media/program11_out.png)\n\n---\n### Program 13\n#### AIM: To Write a Python database connectivity script that creates the table ORDERS in SALES database given below:\n![](media/table.png)\n#### Source code:\n```python\nimport mysql.connector\nconnection=mysql.connector.connect(host=\"localhost\",user=\"root\",password=\"c9070baa\",database=\"sales\")\ncursor = connection.cursor()\ncursor.execute(\"create table ORDERS(ord_no int(5) primary key,purch_amt decimal(8,2),ord_date date, customer_id int(4), salesman_id int (4))\")\ncursor.close()\nconnection.close()\n\n```\n\n#### Output: \n\u003ch1 align=\"center\"\u003eNo Output\u003c/h1\u003e\n\n---\n### Program 14\n#### AIM: insert all the records in the table ORDERS in SALES database.\n#### Source code:\n```python\nimport mysql.connector\nconnection=mysql.connector.connect(host=\"localhost\",user=\"root\",password=\"c9070baa\",database='sales')\ncursor=connection.cursor()\ncursor.execute('''\n                INSERT INTO ORDERS (ord_no, purch_amt, ord_date,customer_id,salesman_id)\n                VALUES\n                (70001,150.5,20121005,3005,5002),\n                (70009,270.65,20120910,3001,5005),\n                (70002,65.26,20121005,3002,5001),\n                (70004,110.5,20120817,3009,5003),\n                (70007,948.5,20120910,3005,5002),\n                (70005,2400.6,20120727,3007,5001),\n                (70008,5760,20120910,3002,5001)\n                ''')\nconnection.commit()\ncursor.close()\nconnection.close()\n\n```\n\n#### Output: \n\u003ch1 align=\"center\"\u003eNo Output\u003c/h1\u003e\n\n---\n### Program 15\n#### AIM: fetch all the recors from ORDERS table of SALES database\n#### Source code:\n```python\nimport mysql.connector\nconnection=mysql.connector.connect(host=\"localhost\",user=\"root\",password=\"c9070baa\",database='sales')\ncursor=connection.cursor()\ncursor.execute('Select * from orders')\nfor x in cursor:\n    print (x)\ncursor.close()\nconnection.close()\n\n```\n\n#### Output: \n\n![](media/program18.png)\n\n---\n### Program 16\n#### AIM: To IDesign a Python application that fetches only those records from ORDERS table of SALES database where salesman_id is 5001.\n#### Source code:\n```python\nimport mysql.connector\nconnection=mysql.connector.connect(host=\"localhost\",user=\"root\",password=\"****!\",database='sales')\ncursor=connection.cursor()\ncursor.execute('Select * from orders where salesman_id=5001')\nfor x in cursor:\n    print (x)\ncursor.close()\nconnection.close()\n```\n\n#### Output: \n\n![](media/program19.png)\n\n---\n### Program 17\n#### AIM: To Design a Python application to obtain a search criteria from user and then fetchs records\n#### Source code:\n```python\nimport mysql.connector\nconnection=mysql.connector.connect(host=\"localhost\",user=\"root\",password=\"c9070baa\",database='school')\ncursor=connection.cursor()\nx=int(input('''\nEnter '1' to search in table GAMES\nEnter '2' to search in table PLAYERS\n'''))\nif x==1:\n    col=input(\"Enter column: \")\n    whereclause=input('Enter where clause: ')\n    cursor.execute('Select {} from games where {}'. format (col,whereclause))\n    record=cursor.fetchall()\n    for i in record:\n        print (i)\nelif x==2:\n    col=input(\"Enter column: \")\n    whereclause=input('Enter where clause: ')\n    cursor.execute('Select {} from player where {}'. format (col,whereclause))\n    record=cursor.fetchall()\n    for i in record:\n        print (i)   \ncursor.close()\nconnection.close()\n\n```\n\n#### Output: \n\n![](media/program20.png)\n\n\n---\n\n\u003ch1 align=\"center\"\u003eSQL\u003c/h1\u003e\n\u003cbr/\u003e\n\n#### Q. Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)\n\n\u003cbr/\u003e\n\n**Table: GAMES**\n\n\u003cbr/\u003e\n\n\u003ctable style=\"width:90%\"\u003e\n    \u003ctr\u003e\n        \u003cth\u003eGCode\u003c/th\u003e\n        \u003cth\u003eGameName\u003c/th\u003e\n        \u003cth\u003eNumber\u003c/th\u003e\n        \u003cth\u003ePrizeMoney\u003c/th\u003e\n        \u003cth\u003eDate\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth\u003e101\u003c/th\u003e\n        \u003cth\u003eCaromBoard\u003c/th\u003e\n        \u003cth\u003e2\u003c/th\u003e\n        \u003cth\u003e5000\u003c/th\u003e\n        \u003cth\u003e23-jan-2004\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth\u003e102\u003c/th\u003e\n        \u003cth\u003eBadminton\u003c/th\u003e\n        \u003cth\u003e2\u003c/th\u003e\n        \u003cth\u003e12000\u003c/th\u003e\n        \u003cth\u003e12-dec-2003\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth\u003e103\u003c/th\u003e\n        \u003cth\u003eTableTennis\u003c/th\u003e\n        \u003cth\u003e4\u003c/th\u003e\n        \u003cth\u003e8000\u003c/th\u003e\n        \u003cth\u003e14-feb-2004\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth\u003e104\u003c/th\u003e\n        \u003cth\u003eChess\u003c/th\u003e\n        \u003cth\u003e2\u003c/th\u003e\n        \u003cth\u003e9000\u003c/th\u003e\n        \u003cth\u003e01-jan-2004\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth\u003e105\u003c/th\u003e\n        \u003cth\u003eLawnTennis\u003c/th\u003e\n        \u003cth\u003e4\u003c/th\u003e\n        \u003cth\u003e25000\u003c/th\u003e\n        \u003cth\u003e19-mar-2004\u003c/th\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cbr/\u003e\n\n**Table: PLAYER**\n\n\u003cbr/\u003e\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003ePCode\u003c/th\u003e\n        \u003cth\u003eName\u003c/th\u003e\n        \u003cth\u003eGCode\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003cth\u003e1\u003c/th\u003e\n        \u003cth\u003eArjun\u003c/th\u003e\n        \u003cth\u003e101\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003cth\u003e2\u003c/th\u003e\n        \u003cth\u003eRavi\u003c/th\u003e\n        \u003cth\u003e105\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003cth\u003e3\u003c/th\u003e\n        \u003cth\u003eJignesh\u003c/th\u003e\n        \u003cth\u003e101\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003cth\u003e4\u003c/th\u003e\n        \u003cth\u003eNihir\u003c/th\u003e\n        \u003cth\u003e103\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003cth\u003e5\u003c/th\u003e\n        \u003cth\u003eSohil\u003c/th\u003e\n        \u003cth\u003e104\u003c/th\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cbr/\u003e\n\n**(i)    To display the name of players who playsCaromBoard.**\n\n`select Name from PLAYER,GAMES where GameName='CaromBoard' and GAMES.Gcode=PLAYER.Gcode;`\n\n#### OUTPUT:\n\n![](media/sql1.png)\n\n**(ii)   To display details of those game which are having PrizeMoney morethan 8000.**\n\n`select * from GAMES where PrizeMoney\u003e8000;`\n\n#### OUTPUT:\n\n![](media/sql2.png)\n\n\n**(iii)  To display the details of those games whose name starts from character ‘B’.**\n\n`select * from GAMES where GameName like 'B%';`\n\n#### OUTPUT:\n\n![](media/sql3.png)\n\n\n**(iv)   To display the details of those games which start after 01-jan-2004.**\n\n`select * from GAMES where date\u003e'2004-01-01';`\n\n#### OUTPUT:\n\n![](media/sql4.png)\n\n\u003cbr/\u003e\n\n**(v)**  `Select COUNT(DISTINCT number) from GAMES;`\n\n#### OUTPUT:\n\n![](media/sql5.png)\n\n**(vi)**  `Select MAX(date), MIN(date) from GAMES;`\n\n#### OUTPUT:\n\n![](media/sql6.png)\n\n**(vii)**  `Select AVG(PrizeMoney) from GAMES Group by Number Having count(GCode)\u003e2;`\n\n#### OUTPUT:\n\n![](media/sql7.png)\n\n**(viii)**  `Select GameName from GAMES Where Date BETWEEN \"2004-01-10\" AND \"2004-02-20\";`\n\n#### OUTPUT:\n\n![](media/sql8.png)\n\n\n\u003ch1 align=\"center\"\u003eSQL: II\u003c/h1\u003e\n\u003cbr/\u003e\n\n#### Q. Consider the following tables EMPLOYEES and EMPSALARY Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)\n\n**(i) To display Fname, Lname, Address and City of all employees living in Mumbai from the\ntable EMPLOYEES.**\n\n`select Fname, Lname, Address, City from Employees where City=\"Mumbai\";`\n\n#### OUTPUT:\n\n![](media/1sql.png)\n\n**(ii) To display the content of EMPLOYEES table in descending order ofFname.**\n\n`SELECT * FROM employees ORDER BY EMPID DESC;`\n\n#### OUTPUT:\n\n![](media/2sql.png)\n\n\n**(iii) To display the Fname, Lname and Total Salary of all Managers from the Table\nEMPLOYEES and EMPSALARY,where Total Salary is calculated as Salary+ Benefits.**\n\n`select Fname, Lname, salary as salary+benifits from employees,empsalary AND EMPLOYEES.EMPID=EMPSALARY.EMPID`\n\n#### OUTPUT:\n\n![](media/3sql.png)\n\n\n**(iv) To display the Maximum Salary among Managers and Clerks from the table EMPSALARY**\n\n`none`\n\n`(v) Select FName, Salary from EMPLOYEES,EMPSALARY where DESIGNATION=‘Salesman’\nAND EMPLOYEES.EMPID=EMPSALARY.EMPID`\n\n#### OUTPUT:\n\n![](media/5sql.png)\n\n`(vi) SELECT Count (Distinct Designation) fromEMPSALARY`\n\n#### OUTPUT:\n\n![](media/6sql.png)\n\n`(vii) SELECT designation, SUM (Salary) from EMPSALARY Group by Designation Havingcount (*)\u003e2;`\n\n#### OUTPUT:\n\n![](media/7sql.png)\n\n`(viii) Select Sum (Benefits) from EMPLOYEES where DESIGNATION\nIN(‘clerk’,‘manager’);`\n\n#### OUTPUT:\n\n![](media/8sql.png)\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevqueue%2Fclass-12-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevqueue%2Fclass-12-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevqueue%2Fclass-12-python/lists"}