Question

In: Computer Science

Question 1 (10) Single screen with information about a the 2020 Olympics Create an application using...

Question 1 (10) Single screen with information about a the 2020 Olympics
Create an application using PyQt. The user must enter the name of an Olympic sport and a single character (e.g ‘a’). The application must read the name of the sport and count the number of occurrences of the character in the sport name. The count should be case-insensitive. Thus, if ‘c’ is entered as the character then both capital letter ‘C’ and small letter ‘c’ in the string should be counted. The count must be displayed. The application interface must include at least a label, an edit and a button. You are welcome to enhance your application with comments and messages.

Solutions

Expert Solution

Souce Code below:-

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


@pyqtSlot()
def count_val():
    gamest = game.text() //gets the text from the lineedit box
    cha = charchtername.text()
    j = 0
    for i in gamest:
        if i == cha:
            j = j + 1 //for each charachter which is equal to the specified character, 1 is added to j.
    count.setText(str(j)) //str(j) will convert the j as a string.


app = QApplication(sys.argv)
win = QWidget()

label1 = QLabel("Enter the sport name:")
game = QLineEdit()

label2 = QLabel("Enter the character:")
charchtername = QLineEdit()

count = QLineEdit()

fb = QFormLayout()
fb.addRow(label1, game)
fb.addRow(label2, charchtername)
fb.addRow(count)

btn = QPushButton("Count")
fb.addRow(btn)
btn.clicked.connect(count_val) //the count_val function will be executed now
win.setLayout(fb)

win.setWindowTitle("test")
win.show()
sys.exit(app.exec_())

Please upvote if you found this useful or drop-in the queries below.


Related Solutions

Create a C# application for SummerSchool that reads the file Participants. participant's data on the screen....
Create a C# application for SummerSchool that reads the file Participants. participant's data on the screen. Create a Participant class that contains field first name, last name, age, and course taken for the summer school and To fields of records in the file are separated with semicolon (). 3 marks) E.g. of a record in the file Participant.txt: 123,John,Smith35:Math using System; using static System. Console; using System. I0; class SummerSchool static void Main() /7Your code as answer
Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information...
Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. Question 2 Redo question 1, but use a different cursor...
Using WORKBENCH: 1. Create the database below via an ER Diagram in Workbench (take screen shots...
Using WORKBENCH: 1. Create the database below via an ER Diagram in Workbench (take screen shots of the diagram) 2. Go to the database table view and take a screen shot of the table(s) 3. Go to the data entry tool and enter at least three lines of data (in each table). Take screen shots. Create a database that is in third normal form for the following: You are a nerd and have decided to organize your comic books in...
Create a mobile application using Android studio, for cinema tickets reservation. The application will be used...
Create a mobile application using Android studio, for cinema tickets reservation. The application will be used by the customers to book cinema tickets. Only users of 15 years old and above are allowed to book cinema tickets for a particular film. The user can book more than one ticket where ticket prices vary between 20 and 50 AED. Your app contains tree Activities. The first activity is a launching activity containing a logo and a button start. When the user...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that can sort a singly-linked-list with Merge-sort. The program should read integers from file (hw-extra.txt) and create an unsorted singly-linked list. Then, the list should be sorted using merge sort algorithm. The merge-sort function should take the head of a linked list, and the size of the linked list as parameters. hw-extra.txt provided: 37 32 96 2 25 71 432 132 76 243 6 32...
Write a program that displays a single character at 100 random screen locations, using a timing...
Write a program that displays a single character at 100 random screen locations, using a timing delay of 100 milliseconds. Hint: Use the GetMaxXY procedure to determine the current size of the console window. How to code this program with a defined character 'A' (I do not want to write a character to get a single character in the output console)
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that...
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that results. create database sample; use sample; create table customer (custno int auto_increment primary key, firstname varchar(20), middle varchar(20), lastname varchar(20), address varchar(60), telnum1 varchar(10), telnum2 varchar(10), telnum3 varchar(10), pin varchar(6), email varchar(30)); create table accttype (id int primary key, type varchar(10)); insert into accttype (id, type) values (1,'check'); insert into accttype (id, type) values (2,'save'); insert into accttype (id, type) values (3,'cd'); insert into...
Database: Question 11 Using the ERD from problem 10, create the relational schema.(Create an appropriate collection...
Database: Question 11 Using the ERD from problem 10, create the relational schema.(Create an appropriate collection of attributes for each of the entities. Make sure you use the appropriate naming conventions to name the attributes.)
Using Java: Create a class that will hold the information about a clock, called Clock. You...
Using Java: Create a class that will hold the information about a clock, called Clock. You need to keep minutes, hours and seconds in military time (24-hour) format. Include member functions that will setTime ( this will set the hours, minutes and seconds of the clock), getHours (return the hours), getMinutes (return the minutes) and getSeconds (return the seconds). Another method printTime which will print the time out like this 03:13:09 (hours:minutes:seconds). Overloaded constructors that will take in hours, minutes...
Treating the two web pages as two views of a Single Page Application (SPA), create the...
Treating the two web pages as two views of a Single Page Application (SPA), create the SPA with two views, one shows what the page in any one question displays and the other shows what the page in other questions  displays
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT