Algorithm代做 | tkinter | 代写Python | assignment – Assignment

Assignment

Algorithm代做 | tkinter | 代写Python | assignment – 这是一个Algorithm面向对象设计的practice, 考察python基本语法和Algorithm的理解, 涵盖了Algorithm/tkinter/Python等程序代做方面, 这是值得参考的assignment代写的题目,偏基础的python练习题目

算法代写 代写算法 Algorithm代写 代写Algorithm  算法作业代写

Objectives:

  • Learn how to use the advanced data structures (such as: list, tuple, string, and dictionary)
  • Learn and practice how to use if-elif-else statements.
  • Learn and practice how to use loops.
  • Learn and practice how to use functions.
  • Appreciate the importance of data validations.
  • Provide appropriate documentation and good programming style.

####### random Generate pseudo-random numbers

random.random()
Return the next random floating point number in the range [0.0, 1.0).

Functions for integers

random.randrange(stop)
random.randrange(start, stop[, step])
  • Return a randomly selected element from range(start, stop, step).
This is equivalent to choice(range(start, stop, step)), but doesnt
actually build a range object.
  • The positional argument pattern matches that of range(). Keyword
arguments should not be used because the function may use them in
unexpected ways.
  • Changed in version 3.2: randrange() is more sophisticated about
producing equally distributed values. Formerly it used a style like
int(random()*n) which could produce slightly uneven distributions.
random.randint(a, b)
  • Return a random integer N such that a <= N <= b.
  • Alias for randrange(a, b+1).

Python 3 – tkinter Button

The Button widget is used to add buttons in a Python application. These
buttons can display text or images that convey the purpose of the
buttons. You can attach a function or a method to a button which is
called automatically when you click the button.

Syntax

Here is the simple syntax to create this widget

w = Button ( master, option = value, … )

Parameters

  • master This represents the parent window.
  • options Here is the list of most commonly used options for this
widget. These options can be used as key-value pairs separated by
commas.

S.No. Option & Description

######## 4

bg
Normal background color.

######## 5

command
Function or method to be called when the button is
clicked.

######## 6

fg
Normal foreground (text) color.

######## 7

font
Text font to be used for the button’s label.

######## 8

height
Height of the button in text lines (for textual buttons) or
pixels (for images).

######## 10

image
Image to be displayed on the button (instead of text).

######## 11

justify
How to show multiple text lines: LEFT to left-justify each
line; CENTER to center them; or RIGHT to right-justify.

######## 12

padx
Additional padding left and right of the text.
13 pady

######## 14

relief
Relief specifies the type of the border. Some of the
values are SUNKEN, RAISED, GROOVE, and RIDGE.

######## 15

state
Set this option to DISABLED to gray out the button and
make it unresponsive. Has the value ACTIVE when the
mouse is over it. Default is NORMAL.

######## 17

width
Width of the button in letters (if displaying text) or pixels
(if displaying an image).

######## 18

wraplength
If this value is set to a positive number, the text lines will
be wrapped to fit within this length.

Example

Try the following example yourself

!/usr/bin/python

from tkinter import *

from tkinter import messagebox

top = Tk() top.geometry(“100×100”) def helloCallBack(): msg = messagebox.showinfo( “Hello Python”, “Hello World”)

B = Button(top, text = “Hello”, command = helloCallBack) B.place(x = 50 ,y = 50 ) top.mainloop()

Result

When the above code is executed, it produces the following result

Example:

!/usr/bin/python

from tkinter import * import random

from tkinter import messagebox

top = Tk() top.geometry(“100×100”)

def helloCallBack(): msg = messagebox.showinfo( “Hello Python”, “Hello World”)

v1 = random.randrange(1, 10,1)

s1 = str(v1) B = Button(top, text = s1, command = helloCallBack) B.place(x = 50,y = 50)

s2 = random.randrange(1, 10,1) B = Button(top, text = s2, command = helloCallBack) B.place(x = 100,y = 50)

top.mainloop()

Python Programming

Description of the problem:

Write a simple menu-driven program called Game of Cards. Each card has
thirteen different numbers. The thirteen possible numbers are: 1 to 1 3. This game has
two cards.
In this game, the maximum bet amount is $ 200 and the minimum bet amount is
$ 5. The amount of the winning prize is directly proportional to the number of matched
cards after the two cards have been generated for each game.

Rules for this game: Initial cash for this game is specified by player. Maximum bet for each game is $ 200. Minimum bet for each game is $ 5. Two cards are used per game. Player can place his or her bet amount for each game. The winning prize is based on how many matched cards have been found: If one matched cards have been found, then the prize is 2 x. If two matched cards have been found, then the prize is 4 x. If no matched card has been found, then the player loses his or her bet for this game-session.

Example of a menu could look like the following:

Optional: The menu-screen could be graphical, instead of text based screen.

Items to be handed in:

  • An Algorithm for this program.
  • A printed copy of your program Python source code and a printout of at least one sample run.
  • All pages must be stapled together. No loose pages are accepted. The disk (USB memory stick) that you hand-in should contain all the related files in a folder called ####assign 4 o where: #### is the last four digit of your student number.
Game of cards
**************************************
  1. Help (display rules for this game)
  2. Enter the total amount of money you bring in the casino for gambling
  3. Roll the cards and then place your bet here (Max. is $50, Min. is $ 1 )
  4. Generate the random numbers for the three cards
  5. Display your gambling results:
    • current cash on hand
    • number of winnings
    • total number of games played so far
  6. Quit
Grading Scheme:
Note:
  • Deduct 5% for each missing feature.
  • Deduct 5% for any incorrect file name or folder name.
  • Deduct 5% for any loose pages.
  • Penalty for late submission of assignments is 5% for the first day, and an additional 10% for each day thereafter.
Your  assignment will be graded according to the following scheme:
Correctness, completeness, and no missing features / 3
General, flexible, and efficient / 2
Documentation, style of code, and sample run / 2
User interface, ingenuity, and overall evaluation / 3
Total: / 10