2. Implement a drawing card game:using python
2.1 Build a class Card() that contains 2 variables: rank and suits
(10 points)
2.2 Build a Deck that contains 52 cards with ranks and suits.
(20 points)
2.3 Two players will take turn to draw two cards from a shuffle
decks. (30 points)
You must implement a function call
playerTurn(deck) to handle a player turn.
playerTurn(deck) should
include these features:
2.3.1 Draw 2 cards from the Deck created in 2.2 2.3.2 Display ranks and suits of these cards
2.3.3 Return the sum of ranks of these cards. Notice that: ‘J’ = 11, ‘Q’ = 12, ‘K’ = 13, and ‘A’ = 1
2.4 The sum results will be compared between 2 players and who gets the larger in total will win that round. Notice that the game needs to keep track total number of player’s win round. (10 points)
2.5 Players have option to repeat as many times as they want. If the users choose ‘Y’, they will continue to draw from the original deck. (The deck will not be shuffled or added during the whole game. In other word, a card cannot be drawn twice during a game). (10 points)
In: Computer Science
Convert decimal 3,712 and 4,132 to both BCD and ASCII codes. For ASCII, an even parity bit is to be apppended at the left.
In: Computer Science
Problem: Given seven 8-mers as listed below
ATCGATAG
GGCCAATT
CGATATCG
AAGCAAGC
AGCGTACG
CCGCATTA
ATCCATCG
1) Create the profile matrix; 2) Derive the consensus; 3) Calculate the consensus score; 4) Calculate the total distance between the 8-mers and the consensus.
In: Computer Science
In: Computer Science
Using the following list and a “for” loop, display differences of all consecutive pairs of numbers in the list. our_list = [1,2,5,6,3,77,9,0,3,23,0.4,-12.4,-3.12] The output should look like this: 1 3 1 … 4.
Using a “while loop” ask the user for a number and add it to a list if number is even and to a different list if number is odd. Keep asking the user for a number until he says “I’m bored” and doesn't want to give you any more numbers.
5. For the following list, print each element in the list an it’s type. list5 = ['a','b',1,2,[1,2,3,4],'hello',(4,5,6),7,True,"False",2.3]
In: Computer Science
In Matlab , Write a script that will print a side-ways triangle pattern of stars in
the command window. The script should ask the user how many stars will be
between the center of the triangle at the base and the tip of the
triangle
In: Computer Science
Solve following tasks using MIPS
Task
Write a program that gets a number from user and
displays “Even”, or “Odd. (If-else)
Write a program that input a number from user displays
each digit separately. For example if input is 3986, output
is 6, 8, 9 ,3. (Loop)
Write a program that converts a decimal number to
binary. (Loop)
Hint for Task 1 and Task 3.
Use, div $tdivident,$tdivider and
mfhi $tdestination instructions.
For example,
Div $t1,$t2 will divide $t1 from $t2 and move the quotient to LOW register and remainder to HI register
mfhi $t3 will move remainder from HIGH register to $t3.
In: Computer Science
Provide a formal proof of the correctness of the algorithm by Boruvka/Solllin for finding a MST.
In: Computer Science
a. (T or F) There can be no code between a try-block and its associated catch-block.
b. (T or F) The reserved word throw is used to signal that an exception has occurred.
c. (T or F) The correct use of throw can be anywhere in a program; a try / catch structure is used only in class definitions.
d. (T or F) In C++, class is not a reserved word.
e. (T or F) Class attributes have no fixed type; their type can be changed during the program execution.
In: Computer Science
In Python, write a program that computes machine epsilon (macheps) in:
Single precision (32 bits) and Double precision (64 bits)
In: Computer Science
Please answer QC,D,E,F using the code provided at the end please.
A. Write C code to define a structure called date that has three fields day, month, year, all of which are ints.
B. Write C code to define a structure called person that has fields for name (50 char array), dateOfBirth (date struct from Q1), address (200 char array), phoneNum (20 char array), and ID (int).
C. Write a C program that uses the person structure from Q2, and declares a variable of this type. Your program should then read information from the keyboard to fill one of these structures with information. Use fgets to read entire lines of text for the name and address rather than scanf.
D. Create another variable that is a pointer to the person structure defined in Q2. Set this variable to point at the variable declared in Q3, and then use the pointer to print the structure to the screen (with appropriate text).
E. Show how a typedef statement can be used to declare a new data type – to demonstrate this create a new type called Person which is the structure declared previously.
F. . Write C code to declare an array of 50 pointers to Persons. Using a loop, use malloc to dynamically allocate memory for each of these structures. There is no need to put any values into the structures. Use a second loop to then deallocate each structure.
__________________________________________________________________________________________________________________________
#include<stdio.h>
#include<stdlib.h>
#define NAME_SIZE 50
#define address_SIZE 200
#define phone_SIZE 20
// Part A defining the structure
struct Date{
int day, month, year;
};
// Part B defining the Person structure
struct Person{
char name[NAME_SIZE];
struct Date dateOfBirth;
char address[address_SIZE];
int id;
char phoneNumber[phone_SIZE];
};
// Main function for the same
int main(){
// part C defining the variable for the use of above structure
struct Person p;
// Just to make the inputs go flowlessly
char newLine;
// Taking the user input
printf("Enter the person name: ");
fgets(p.name, NAME_SIZE, stdin);
printf("Enter dob in 'day month year' Format");
scanf("%d%d%d", &p.dateOfBirth.day, &p.dateOfBirth.month, &p.dateOfBirth.year);
scanf("%c", &newLine);
printf("Enter the address: ");
fgets(p.address, address_SIZE, stdin);
printf("Enter the id: ");
scanf("%d", &p.id);
scanf("%c", &newLine);
printf("Enter the phone number: ");
fgets(p.phoneNumber, phone_SIZE, stdin);
// part D defining the pointer for the person
struct Person* p2;
p2 = &p;
// Printing the Scanned values
printf("Printing the populated Person Structure\n");
printf("Name: %s\n", p2->name);
printf("DOB: %d %d %d\n", p2->dateOfBirth.day, p2->dateOfBirth.month, p2->dateOfBirth.year);
printf("Address: %s\n", p2->address);
printf("Id: %d\n", p2->id);
printf("Phone: %s\n", p2->phoneNumber);
In: Computer Science
Write a program that prompts the user for the length of one side of a triangle and the sizes of the two adjacent angles in degrees and then displays the length of the two other sides and the size of the third angle.
In: Computer Science
implement a formula of your own choosing, as a Python function, following these instructions:
In: Computer Science
4 function calculator (op1 oper op2) using scheme
language
also include comments
In: Computer Science
C# Language
In: Computer Science