1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Temka [501]
2 years ago
11

Python

Computers and Technology
1 answer:
kramer2 years ago
3 0

The program illustrates the use of loops .

Loops are used for operations that must be repeated until a certain condition is met.

<h3>How to write the program?</h3>

The program written in Python, where comments are used to explain each action is as follows:

#This defines the int_to_reverse_binary function

def int_to_reverse_binary(integer_value):

   #This initializes the string output

   strNum = ""

   #The following loop calculates the string output

   while (integer_value > 0):

       strNum += str(integer_value % 2)

       integer_value //= 2

   #This passes the string output to the string_reverse function

   string_reverse(strNum)

#This defines the string_reverse function

def string_reverse(input_string):

   #This reverses the string

   strRev = input_string[::-1]

   #This prints the reversed string

   print("Binary number:",strRev)

# The main begins here

if __name__ == '__main__':

   #This gets the decimal value

   dec_val = int(input("Decimal value: "))

   #This calls the int_to_reverse_binary function

   int_to_reverse_binary(dec_val)

   

Read more about Python programs at:

brainly.com/question/24833629

You might be interested in
Declaring a member as ____ in the base class provides access to that member in the derived classes but not to anyone else. a. pu
Sidana [21]

When a member is declared as b. <u>protected</u> in the base class, it provides access to that member in the derived classes but not to anyone else.

<h3>What is a derived class?</h3>

A derived class can be defined as a type of class that inherits the information or members of a base (parent) class such as a car in a syntax.

Basically, a public class is accessible to everybody while a private class can only be accessed by users within the declared class. Also, a constant is a class whose value remains unchanged.

In Computer programming, when a member is declared as <u>protected</u> in the base class, it ultimately provides access to that member only in the derived classes but not to other members or anyone else.

Read more on data types here: brainly.com/question/20264183

#SPJ1

6 0
2 years ago
10011÷11 binary division​
Nostrana [21]

Answer:

110.01001

Explanation:

it's a repeating decimal

6 0
3 years ago
Write a C program that counts the number of vowels in a word. The C program reads words from an input file and then stores in an
polet [3.4K]

Answer:

Explanation:

The following code is written in C and does what the question requires. It uses the input file reads it and outputs the number of vowels to the file called output.dat

#include <ctype.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int str_count_in_chars(char *start, char *end, char *chars) {

   int count = 0;

   for (; start != end; count += !!strchr(chars, *(start++)));

   return count;

}

void str_swap_in_chars(size_t str_len, char **str, char *chars) {

   for (int front = 0, back = str_len - 1; front < back; front++) {

       if (strchr(chars, (*str)[front])) {

           for (; !strchr(chars, (*str)[back]); back--);

           char tmp = (*str)[front];

           (*str)[front] = (*str)[back];

           (*str)[back--] = tmp;

       }

   }

}

char *file_to_str(FILE *fin) {

   int buf_len = 64;

   char buf[buf_len];

   char *str = malloc(buf_len);

   str[0] = '\0';

   for (int i = 1; fgets(buf, buf_len, fin); i++) {

       if (!(str = realloc(str, i * buf_len))) {

           fprintf(stderr, "%s:%d realloc failed\n", __FILE__, __LINE__);

           exit(1);

       }

       strcat(str, buf);

   }

   return str;

}

int main() {

   char *vowels = "aeiou";

   FILE *fin = fopen("input.dat", "r");

   FILE *fout = fopen("output.dat", "w");

   if (!fin || !fout) {

       fprintf(stderr, "%s:%d fopen failed\n", __FILE__, __LINE__);

       exit(1);

   }

   char *words = file_to_str(fin);

   fclose(fin);

   int words_len = strlen(words);

   for (int i = 0; i < words_len;) {

       if (isspace(words[i])) {

           fputc(words[i++], fout);

           continue;

       }

       int start = i;

       for (; i < words_len && !isspace(words[i]); i++);

       char *word = words + start;

       int word_len = i - start;

       int vowel_count = str_count_in_chars(word, words + i, vowels);

       if (vowel_count % 2 == 0) {

           str_swap_in_chars(word_len, &word, vowels);

       }

       fprintf(fout, "%.*s_%dvow", word_len, word, vowel_count);

   }

   fclose(fout);  

   free(words);

   return 0;

}

5 0
3 years ago
What are the differences between tkinter toolkit and PyQt?
lesantik [10]

Answer:

See the explanation  

Explanation:

tkinter toolkit                                            

  • Easy to use
  • Easy to learn
  • Easy to debug
  • Good for simple tasks
  • TkInter applications are simpler as compared to PyQt because it is included in standard Python distribution.
  • Faster than PyQt.
  • Does not have advanced widgets.
  • No interface builder available.
  • Free for commercial utilization.

PyQt

  • More flexible in terms of coding.
  • Harder to debug as compared to tkinter
  • GUI is clearer in display than tkinter
  • Widgets are more interactive than that of tkinter
  • size of a PyQt program is larger than that of tkinter
  • uses a variety of paltform APIs and gives primary access to these APIs through a unique API.
  • Has an interface builder that allows to design interfaces without writing any code.
  • Has modern widgets.
  • Due to its vast interface and several UI components it is a bit confusing to learn as compared to tkinter.
  • Commercial license is required to release the code.
  • Cross-platform and native GUI.

Widgets are GUI components such as buttons, labels, menus.

a) Label

This is a tkinter widget to show the text or image on the screen. It looks like a display box. The user can easily edit or update label.

For example to display a label with text "Hello World" the following chunk of code is used:

import tkinter

widget = tkinter.Tk()

label =tkinter.Label(widget, text="Hello World")

label.pack()

tkinter.mainloop()

b) Entry

This is a tkinter widget to accept the text input from user. For example if you want to get a single line text from user then you can use Entry widget. The code below displays an entry widget with the message: Enter input text: Here the user can input the text.

import tkinter

widget = tkinter.Tk()

entry = tkinter.Entry(widget)

entry.insert(0, "Enter input text:")

entry.pack()

tkinter.mainloop()

c) Button

This is a tkinter widget to add a button in an application. You can enter some text or an image in this button convey its purpose. When you click on the button a function is called or an event is emitted.

The following chunk of code displays a button with the text "Click Me" on the button.

import tkinter

widget = tkinter.Tk()

button = tkinter.Button(widget, text="Click Me")

button.pack()

tkinter.mainloop()

d) Frame

This is a tkinter widget to group together and organize other widgets and arranges their position.

The following chunk of code displays an outer frame with a label with text "parent label" and an inner frame with a label of text "child frame".

import tkinter

widget = tkinter.Tk()

frame = tkinter.LabelFrame(widget,text="parent frame")  

label= tkinter.Label(frame,text="child frame")

frame.pack(padx=10, pady=10)

label.pack()

tkinter.mainloop()

5 0
4 years ago
What should you do before you share your information on the internet?
satela [25.4K]

You have to think about, what could happen to you if you shared this information.

Hope this helped!

~Izzy

4 0
3 years ago
Other questions:
  • _ are typically comprised of a mix of _ and _
    11·2 answers
  • What actions are considered positive body language?
    12·1 answer
  • Understanding the context of information allows you to apply it to everyday situations as opposed to just___facts like names,dat
    12·1 answer
  • How do you make Thumbnails and outros on Youtube for free?
    8·1 answer
  • Ted is looking for a reliable source for his paper. Which of the following sites would be considered reliable?
    5·1 answer
  • A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in
    15·1 answer
  • Which of the following statements are true about the code shown below in the class named Quiz? (Select all that apply.)
    7·1 answer
  • 4. Describe a report that a company might want to create and run on a regular basis. (1-3
    10·1 answer
  • How is unqualified assumptions a disadvantage of communication​
    14·1 answer
  • Decades of research throughout the world have found a _____ correlation between academic achievement and socioeconomic status, l
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!