ruby programming exercises

Want to know ruby programming exercises? we have a huge selection of ruby programming exercises information on alibabacloud.com

Practice LNMP full-process Shell programming: if syntax exercises, lnmpshell

Practice LNMP full-process Shell programming: if syntax exercises, lnmpshell #! /Bin/bash # DATE: wed Jan 17 1 # ywyankerp@163.com # this is a yankerp # The Nginx service is being installedROOT_ID = 0 ML =/usr/local/srcNGINX_ML =/usr/local/src/nginx-1.12.2PML =/usr /local/src/php-5.6.27QD = 'netstat-anpt | grep 80 | awk '{print $7}' | cut-d "/"-f2 | cut-d ": "-f1 'addr = 'IP a | grep eno16777728 $ | awk' {p

C # object-oriented programming exercises,

C # object-oriented programming exercises, Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace ConsoleApplication1 {class Program {public class apple {public string info; public apple () {} public string app (string [] a) {foreach (string value in) info + = value + "+"; info = info. substring (0, info. length-1); return info ;}

Python core programming-exercises-Chapter 2, Chapter 2

Python core programming-exercises-Chapter 2, Chapter 2 PS: PDF online address: http://bcmi.sjtu.edu.cn /~ Zhaohai/ptm2012/data/Python-kernel.programming.v2.pdf 2-1 variables, print and string formatting operators. Start the interactive interpreter, assign values (strings, values, and so on) to some variables, and display their values by entering the variable names. Use the print statement to do the same thi

Java Programming Basics Array Exercises

= Numbers[1]; + } - Else the { *max = Numbers[1]; $SEC = Numbers[0];Panax Notoginseng } - for(inti = 2; I ) the { + if(Numbers[i] >max) A { theSEC =Max; +Max =Numbers[i]; - } $ Else $ { - if(Numbers[i] >sec) - { theSEC =Numbers[i]; - }Wuyi } the } -SYSTEM.OUT.PRINTLN ("Maximum number:" + Max + "followed by:" +sec); Wu

Python core programming chapter seventh exercises

7-9. Translation(a) writing a character translation program (functionally similar to the TR command in Unix). We call this function tr (), which hasThree string parameters: source string, Destination string, basic string, syntax is defined as follows:def tr (Srcstr, DSTSTR, String)The content of Srcstr is the character set that you intend to "translate", Dsrstr is the character set that is obtained after translation, and string isThe string to which you intend to perform the translation operatio

C++primer Chapter Two programming exercises answer

);intMain () {using namespacestd; DoubleLight_years; cout"Enter the number of light years:"; CIN>>Light_years; Cin.Get(); cout"Light years =""Astronomical Units"; Cin.Get();}DoubleConvertDoublelight_years) { DoubleUnits = Light_years *63240; returnunits;}2.7.7#include voidTimerint,int);intMain () {using namespacestd; inthours, minutes; cout"Enter the number of hours:"; CIN>>hours; cout"Enter the number of minutes:"; CIN>>minutes; Cin.Get(); Timer (hours, minutes); Cin.Get();}voidTimerintHo

Rectification C + + programming Chapter 10th of the first class exercises

#include using namespacestd;intMain () {intA,b,c; cout"Please enter a number of three integer types:"Endl; CIN>>a>>b>>C; voidSortintXintYintz); Sort (a,b,c);//ABC has a specific value, called the actual parameter return 0;} voidSortintXintYintZ//used to receive actual parameters, called formal parameters{ inttemp; if(x>y) {temp=x;x=y;y=temp; } if(zx) cout','','Endl; Else if(z','','Endl; Elsecout','','Endl;}Rectification C + + programming Chap

Rectification C + + programming Chapter 7th of the first class exercises

#include using namespacestd;intMain () {intA,b,c; intFintXintYintZ);//this is the declaration of the function//CIN Sonsole Consolecout"Please enter a number of three integer types:"Endl; CIN>>a>>b>>B; C=f (A,B,C);//ABC has a specific value, called the actual parametercoutEndl; return 0;}intFintXintYintZ//used to receive actual parameters, called formal parameters{ intm; if(xy) M=x; Elsem=y; if(zm) m=Z; return(m);}Rectification C + + programming Cha

Bash Shell programming Exercises

document after adding the line number (blank line):[Email protected] ~/t2scripts $ cat-b E.log |Tee E3.log1/etc/passwd2Find: '/etc/ntp/crypto': Permission denied 3Find: '/etc/audisp': Permission denied 4Find: '/etc/audit': Permission denied 5Find: '/etc/polkit-1/localauthority': Permission denied 6Find: '/etc/dhcp': Permission denied 7/etc/pam.d/passwd8Find: '/etc/lvm/backup': Permission denied 9Find: '/etc/lvm/cache': Permission denied TenFind: '/etc/lvm/archive': P

Network programming Exercises--Post-json data

Lwtviewcontroller.m////LWTVIEWCONTROLLER.M//Network Programming Exercises--Post-json data////Created by Apple on 14-7-2.//Copyright (c) 2014 LWT. All rights reserved.//#import "LWTViewController.h"@interfaceLwtviewcontroller ()@end@implementationLwtviewcontroller- (void) viewdidload{[Super Viewdidload]; //additional setup after loading the view, typically from a nib.}- (void) Touchesbegan: (Nsset *) touches

Python Core Programming _ the fifth chapter after class exercises

Exercise 5_2.py#!/usr/bin/pythondef mymultiple (x, y): return x * y for I in range (1, ten): for J in range (1, i + 1): print '%d *%d =%2d '% (j, I, Mymultiple (i, J)), if j = = I:printExercise 5_3.py#!/usr/bin/env pythoninputscore = Int (raw_input (' Input a Integer: ')) if Inputscore >= 90:print ' Your score is a (90 ~100) ' elif inputscore >= 80:print ' Your score are B (80~89) ' elif inputscore >= 70:print ' Your score is C (70~ () ' Elif inputscore >= 60:print ' Your score is D (60~69) ' El

Java Programming Ideas Fourth Edition Chapter three key exercises

reference type, when he is directly assigned to the value of the corresponding reference position is assigned to the string variable, so, two times the result is true. If you assign a value with the new String (), the result will be different. Write a program that simulates the result of tossing a coinPackage Net.mindview.operators;import Java.util.random;importStaticnet.mindview.util.print.*; Public classThrowcron { Public Static voidMain (string[] args) {Random num=NewRandom (); intA = Num.

"Python Programming Quick Start" 7.18.2 practical exercises

# -*- coding:utf-8 -*-#strip正则表达式#if 只字符串,不带参数,去首尾空白#else 去除参数text=input("Input a text:")import redef st(text): #原样返回检测 textReg=re.compile(r"^\w+$") #前后或前或后,空白检测 blankReg=re.compile(r‘^\s+(\w+)\s+$|^\s+(\w+)|(\w+)\s+$‘) check_blank=blankReg.search(text) #参数检测 argsReg=re.compile(r‘(\w+)\s+\.*‘) check_args=argsReg.search(text) if textReg.search(text): return(text) elif check_blank: #groups检测,直接通过groups输出 for i in check_blank.groups(): if i: return(i) elif check_args: return(check_args.group(1)) el

"Python Programming Quick Start" 7.18.1 practical exercises

# -*- coding:utf-8 -*-# 7.18.1# 强口令检测# 写一个函数,使用正则表达式,确保传入的口令字符串是强口令# 长度不少于8个字符,同时包含大小写,至少有1个数字import repassd=input("Input your password:")ch_len=re.compile(r‘.{8,}‘)ch_uppercase=re.compile(r‘[A-Z]{1,}‘)ch_case=re.compile(r‘[a-z]{1,}‘)ch_number=re.compile(r‘\d{1,}‘)if ch_len.search(passd): if not ch_case.search(passd) or not ch_uppercase.search(passd) or not ch_number.search(passd) : print("弱密码") else: print("strong enough")else: print("length less then 8")"Python

"Python Programming Quick Start" 8.9.3 practical exercises

#!python3# -*- coding:utf-8 -*-# 8.9.3#打开指定路径中所有.txt文件#用户输入正则,将匹配行输出,输出文件名import re,ospat=input("输入要处理的文件夹绝对路径:")lis_dir=os.listdir(pat)lis_txt=[]for x in lis_dir: #取出.txt结尾的文件名,加进列表 if re.search(r‘\.txt$‘,x): lis_txt.append(x)text=input("输入你的自定义正则表达式:")regCom=re.compile(text)#regCom=re.compile(‘.*name.*‘)#循环处理文件for fi in lis_txt: fi=os.path.join(pat,fi) fi_open=open(fi) for fi_line in fi_open.readlines(): fi_reg=regCom.search(fi_line) if fi_reg: print(fi_reg.group()) fi_open.close()print("查找完成"

"Python Programming Quick Start" 8.9.1 practical exercises

#!python3#运行 py mcb.pyw save spam ,剪贴板内容就关键字spam保存#py mcb.pyw spam 加载spam 对应内容到剪贴板#py mcb.pyw list 关键字列表到剪贴板#扩展多重剪贴板:#增加delete "Python Programming Quick Start" 8.9.1 practical exercises

Java Programming Ideas (Fourth Edition) * Chapter II Personal exercises

Create a class that contains an int field and a char field that are not initialized and print them out to verify that Java performs the default initialization.public class Domtest{int I;char c;public domtest () {System.out.println ("i=" +i+ "\nc=[" +c+ "]" + "\ n []");/** * Print result as follows I =0 c=[] []//only for comparison reference */}/** * @param args */public static void main (string[] args) {new domtest ();}}Java Programming Ideas (Fourt

Python core programming chapter sixth after-class exercises

numbers, ranging from large to small. (b) is the same as a, but it is arranged in a dictionary order from large to small. " # (a) Defget_num (): globalnum_listnum_list= []num= ' whilenum!= '! ': num=raw_input (' Enter some numbers to '! "End"). Strip () ifnum!= '! ': try: num=float (num) except: print ' input is wrong, please re-enter ' get_num () else: num_list.append (num) else: breakreturnnum_listdefsort_descending (): get_num () printsorted (num_list,reverse=true) print '---------------

Java Programming Ideas Fourth Edition Nineth chapter exercises

Third questionPackage net.mindview.interfaces;Abstract classbase{ PublicBase () {print (); } Abstract voidprint ();} Public classTest3 extends base{Private inti =5; @Overridevoidprint () {System. out. println (i); } Public Static voidMain (string[] args) {Test3 T=NewTest3 (); T.print (); }}Output Result:0 5When calling the base class construction method, it simply allocates a chunk of memory space to the member variable of the subclass and sets the value of the memory space to the defa

Python Core Programming 2 Chapter two after-school exercises

! " Break Else : Pass2-11#!/usr/etc/env python#-*-coding:utf-8-*-MyList =[]i=0sum=0 whileI: Counter=input ("Please enter the number:\n") MyList+=[counter] I+=1 whileTrue:Print"""(1) Take Five numbers and (2) Take five numbers of the average (3) Exit"""Choose=input ("Please enter your choose:\n") ifChoose==1: forJinchRange (len (myList)): Sum+=Mylist[j]Printsumelifchoose==2: forJinchRange (len (myList)): Sum+=Mylist[j]P

Total Pages: 14 1 .... 10 11 12 13 14 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.