ExercisesΒΆ

There may be exercises below contributed by professors using Runestone.

Contributed ExercisesΒΆ

The below lists contain information on groceries: the SKU code, product category, brand, product name, price, and unit size.

Your program should allow the select a report to display. The reports should display:

  1. The number of products from each brand.

  2. A listing of all products with their product name, price, unit size, and per-unit cost.

  3. The average per-unit cost for each product category.

You can add additional features to the program if you like.

You may use features and modules not covered in class. If your code requires modules not supported by Runestone to run, please indicate that in a comment and list where you have successfully run your program.

The below lists contain information on groceries: the SKU code, product category, brand, product name, price, and unit size.

Your program should allow the select a report to display. The reports should display:

  1. The number of products from each brand.

  2. A listing of all products with their SKU code, product name, price, unit size, and per-unit cost.

  3. The average per-unit cost for each product category.

You can add additional features to the program if you like.

You may use features and modules not covered in class. If your code requires modules not supported by Runestone to run, please indicate that in a comment and list where you have successfully run your program.

The following has the correct code to β€˜swap’ the values in x and y (so that x ends up with y’s initial value and y ends up with x’s initial value), but the code is mixed up and contains <b>one extra block</b> which is not needed in a correct solution. Drag the needed blocks from the left into the correct order on the right. Check your solution by clicking on the <i>Check Me</i> button. You will be told if any of the blocks are in the wrong order or if you need to remove one or more blocks.

        int x = 3;
int y = 5;
int temp = 0;
---
temp = x;
---
x = y;
---
y = temp;
---
y = x; #distractor
        

Put the code pieces in the right order so that the following number sequence is printed: 4 6 8

        k = 4
---
while k < 9:
---
    print(k)
---
    k = k + 2
        
Q-1: Characterize the Crossword puzzle environment

Partially

Single

Deterministic

Episodic

Static

Discrete

Fully

Multi

Stochastic

Sequential

Dynamic

Continuous

Q-1: Characterize Medical diagnosis environment

Partially

Single

Deterministic

Episodic

Static

Discrete

Fully

Multi

Stochastic

Sequential

Dynamic

Continuous

In the code window below, write your Python code that solves the exam exercise labeled Ex 1 Essay 3 in the Canvas exam window.

Include your name where indicated; do not change any of my starter code. This is not an autograded question, so be certain your code works as it should before answering Done to the Canvas question.

In the code window below, write your Python code that solves the exam exercise labeled Ex 1 Essay 4 in the Canvas exam window.

Include your name where indicated; do not change any of my starter code. This is not an autograded question, so be certain your code works as it should before answering Done to the Canvas question.

In the recent SETI/Common Words project, you worked with a file of the 5000 most common words in English. (You may also wish to review that project in the text for more info on the fields in that CSV file.)

This exercise is the last exercise in that project. Using altair, let’s look at the distribution of the different parts of speech in this 5000 word dataset. Create a bar chart, where the part of speech is on the x-axis and the number of words on that list which fall into that category is on the y-axis.

(Remember our altair examples handout.)

If you want to check your work, your graph should look something like this graph.

Buatlah fungsi cariFaktor yang inputnya adalah bilangan asli dan mengembalikan (return) list faktor-faktor pembaginya.

Jika input yang diberikan bukan bilangan asli yang dikembalikan adalah string "bukan bilangan asli"

Contoh: cariFaktor(12) akan menghasilkan [1, 2, 3, 4, 6, 12]

Data file: tryout01.txt
Kuliah Pemrograman Komputer di jurusan Fisika menggunakan python di Runestone.
Python adalah bahasa pemrograman yang paling populer di dunia.
Python diciptakan oleh Guido van Rossum.
Cara membuat program yang tidak hanya benar tapi mengikuti konvensi komunitas python disebut pythonic program.
Selamat belajar python
Data file: uts02.txt
Kuliah Pemrograman Komputer di jurusan Fisika menggunakan python di Runestone.
Python adalah bahasa pemrograman yang paling populer di dunia.
Python diciptakan oleh Guido van Rossum.
Cara membuat program yang tidak hanya benar tapi mengikuti konvensi komunitas python disebut pythonic program.
Selamat belajar python

Baca file tryout01.txt kemudian buat list setelah_Python yang berisi setiap kata setelah kata Python atau python tapi bukan kata yang berbeda seperti phyton atau pythons

Jika perlu print seluruh isi file tersebut untuk dipelajari.

Buatlah fungsi jumlahSalaman(n) untuk menghitung jumlah salaman dalam satu pertemuan yang dihadiri oleh n pasangan. Jika setiap orang berpasangan dengan semua orang kecuali pasangannya sendiri.

Buatlah fungsi cariFaktor yang inputnya adalah bilangan asli dan mengembalikan (return) list faktor-faktor pembaginya.

Jika input yang diberikan bukan bilangan asli yang dikembalikan adalah string "bukan bilangan asli"

Contoh: cariFaktor(12) akan menghasilkan [1, 2, 3, 4, 6, 12]

Susunlah fungsi berikut untuk menghitung jumlah elemen dari nested data. Contoh datanya: nested = [[β€˜a’, β€˜b’, β€˜c’],[β€˜d’, β€˜e’],[β€˜f’, β€˜g’, β€˜h’]]

        def hitung_elemen(n):
---
    hitung = 0
---
    for l in n:
---
        for x in l:
---
            hitung = hitung + 1
---
    return hitung
        

Hitunglah luas di bawah fungsi y(x)=sin(x) untuk 0<x<pi Generate: bilangan random untuk 0<x<pi dan 0<y<1

Jika y < sin(x) catat n = n+1

Ulangi N kali dengan N = 1000

Luas tersebut disimpan pada variabel luas

Hitunglah luas di bawah fungsi y(x)=sin(x) untuk 0<x<pi

mean(y(x)) = luas / (batas_atas - batas_bawah)

Luas tersebut disimpan pada variabel luas

Buatlah class Kompleks untuk menghitung operasi + dan * bilangan kompleks

Buatlah sebuah program untuk mengetest apakah password yang kamu buat itu valid atau tidak valid, sesuai dengan ketentuan yang berlaku: Harus memuat komponen : [a-z]; Harus memuat komponen : [A-Z]; Harus memuat komponen : [0-9]; Harus memuat komponen : [$#@].

Susunlah fungsi berikut untuk mendapatkan hasil : Calling child constructor; Calling child method; Calling parent method; Parent attribute : 200.

        class Parent:
   parentAttr = 100
   def __init__(self):
      print ('Calling parent constructor')
---
   def parentMethod(self):
      print ('Calling parent method')
---
   def setAttr(self, attr):
      Parent.parentAttr = attr
---
   def getAttr(self):
      print ('Parent attribute :', Parent.parentAttr)
---
class Child(Parent):
   def __init__(self):
      print ('Calling child constructor')
---
   def childMethod(self):
      print ('Calling child method')
---
   c = Child()
   c.childMethod()
   c.parentMethod()
   c.setAttr(200)
   c.getAttr()
        

Hitunglah luas daerah antara y = 1/x + 1 dan sumbu-x dan x=1 dan x=batas_atas. Tingkatkan akurasi hingga error < 0.001 setelah diulang 5 kali berturut-turut.

I have provided you with the hidden lists loan_amount, country_name, time_to_raise, and num_lenders_total from our Kiva project. (from class on Thu Feb 25).

For each unique country name, print a line that shows the name of the country and then the number of loans made in that country, like this: β€œGuatemala 1”

I have provided you with the hidden lists loan_amount, country_name, time_to_raise, and num_lenders_total from our Kiva project. (from class on Thu Feb 25).

Write Python code to determine the name of the country with the loan that took the longest time to raise? Store your result in the variable longest_to_fund

config values (conf.py):

  • activecode_div_class - custom CSS class of the component’s outermost div

  • activecode_hide_load_history - if True, hide the load history button

  • wasm_uri - Path or Full URL to folder containing WASM files for SQL. /_static is default

config values (conf.py):

  • activecode_div_class - custom CSS class of the component’s outermost div

  • activecode_hide_load_history - if True, hide the load history button

  • wasm_uri - Path or Full URL to folder containing WASM files for SQL. /_static is default

You have attempted of activities on this page